Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tarunsha009/blog-platform
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.
https://github.com/tarunsha009/blog-platform
blog flask flask-sqlalchemy postgresql rest-api sqlalchemy
Last synced: about 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/tarunsha009/blog-platform
- Owner: tarunsha009
- License: mit
- Created: 2024-07-01T09:05:43.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-07-08T14:03:30.000Z (6 months ago)
- Last Synced: 2024-07-09T00:35:38.103Z (6 months ago)
- Topics: blog, flask, flask-sqlalchemy, postgresql, rest-api, sqlalchemy
- Language: Python
- Homepage:
- Size: 108 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 51
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 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**
```sh
git clone https://github.com/yourusername/your-repository.git
cd your-repository
```2. **Set Up Your Environment**
Create and activate a virtual environment:
```sh
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
```3. **Install Dependencies**
```sh
pip install -r requirements.txt
```4. **Configure the Application**
Set up your configuration values in `blog_platform/config.py`. Update the following variables:
```python
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:
```sh
python blog_platform/manage.py runserver
```## Authentication Endpoints
### User Registration
- **URL**: `/blog/User/register`
- **Method**: `POST`
- **Description**: Register a new user.
- **Request Body**:```json
{
"username": "exampleuser",
"password": "examplepassword"
}
```- **Response**:
```json
{
"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**:```json
{
"username": "exampleuser",
"password": "examplepassword"
}
```- **Response**:
```json
{
"access_token": ""
}
```### User Logout
- **URL**: `/blog/User/logout`
- **Method**: `POST`
- **Description**: Log out the currently logged-in user by invalidating the JWT token.
- **Headers**:```http
Authorization: Bearer
```- **Response**:
```json
{
"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**:```http
Authorization: Bearer
```- **Response**:
```json
{
"message": "This is a protected route."
}
```## Running Tests
To run the tests, use the following command:
```sh
pytest
```
## ContributingTo contribute to the Blog Platform project:
1. **Create a Branch**: Create a branch for your feature or bug fix.
```sh
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](LICENSE) file for details.