Skip to content

A feature-rich, secure, and scalable blog platform built with Flask and SQLAlchemy. Includes user authentication, post management, comments, notifications, localization, and more. Ideal for learning backend development.

License

Notifications You must be signed in to change notification settings

tarunsha009/Blog-Platform

Repository files navigation

Blog Platform

Description

A RESTful API for a blog platform built with Flask and PostgreSQL. This project features a comprehensive system for user management, blog post handling, comment management, notifications, and reporting. It includes secure authentication mechanisms with JWT tokens and a protected route example. The project also supports localization and internationalization.

Features

  • User Authentication: Register, log in, and log out users with JWT tokens.
  • Blog Post Management: Create, read, update, and delete blog posts.
  • Comment System: Add, view, update, and delete comments on blog posts.
  • Notifications: Receive notifications for comments on blog posts.
  • Reporting System: Report blog posts.
  • Localization and Internationalization: Support for multiple languages.
  • Protected Routes: Examples of routes protected by authentication tokens.

Getting Started

To get started with the Blog Platform API, follow these steps:

  1. Clone the Repository

    git clone https://github.com/yourusername/your-repository.git
    cd your-repository
  2. Set Up Your Environment

    Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate   # On Windows, use `venv\Scripts\activate`
  3. Install Dependencies

    pip install -r requirements.txt
  4. Configure the Application

    Set up your configuration values in blog_platform/config.py. Update the following variables:

    class Config:
        SECRET_KEY = 'your_secret_key'
        SQLALCHEMY_DATABASE_URI = 'postgresql://username:password@localhost:5432/your_database'
        REDIS_URL = 'redis://localhost:6379/0'
  5. Run the Application

    Start the application with:

    python blog_platform/manage.py runserver

Authentication Endpoints

User Registration

  • URL: /blog/User/register

  • Method: POST

  • Description: Register a new user.

  • Request Body:

    {
        "username": "exampleuser",
        "password": "examplepassword"
    }
  • Response:

    {
        "message": "User registered successfully."
    }

User Login

  • URL: /blog/User/login

  • Method: POST

  • Description: Log in an existing user and receive a JWT token.

  • Request Body:

    {
        "username": "exampleuser",
        "password": "examplepassword"
    }
  • Response:

    {
        "access_token": "<JWT_TOKEN>"
    }

User Logout

  • URL: /blog/User/logout

  • Method: POST

  • Description: Log out the currently logged-in user by invalidating the JWT token.

  • Headers:

    Authorization: Bearer <JWT_TOKEN>
  • Response:

    {
        "message": "User logged out successfully."
    }

Protected Route Example

  • URL: /protected

  • Method: GET

  • Description: Example of a protected route that requires a valid JWT token.

  • Headers:

    Authorization: Bearer <JWT_TOKEN>
  • Response:

    {
        "message": "This is a protected route."
    }

Running Tests

To run the tests, use the following command:

pytest

Contributing

To contribute to the Blog Platform project:

  1. Create a Branch: Create a branch for your feature or bug fix.

    git checkout -b feature/your-feature
  2. Make Changes: Implement your changes and test them.

  3. Submit a Pull Request: Submit a pull request with a description of your changes.

    • Ensure that your code adheres to the project's coding standards.
    • Provide clear descriptions of the changes and the reasons behind them.
    • Include tests and documentation updates as needed.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A feature-rich, secure, and scalable blog platform built with Flask and SQLAlchemy. Includes user authentication, post management, comments, notifications, localization, and more. Ideal for learning backend development.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages