A RESTful API built with Flask and MySQL for managing blog posts with categories and tags.
Project URL: https://roadmap.sh/projects/blogging-platform-api
- CRUD operations for blog posts
- Category management
- Tag management
- Database transaction handling
- Error handling and validation
- Python 3.x
- Flask
- MySQL
- python-dotenv
- Clone the repository
- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install flask mysql-connector-python python-dotenv- Create a
.envfile with the following variables:
DB_HOST=your_host
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=blogging_platform
- Initialize the database:
python create_db.py
mysql -u your_username -p blogging_platform < init.sqlGET /posts- Get all postsPOST /posts- Create a new postGET /posts/<id>- Get a specific postPUT /posts/<id>- Update a specific postDELETE /posts/<id>- Delete a specific post
{
"title": "Post Title",
"content": "Post Content",
"category": "Technology",
"tags": ["Coding", "Tech News"]
}categories- Stores blog categoriestags- Stores available tagsposts- Stores blog postspost_tags- Junction table for post-tag relationships
python app.pyThe server will start on http://localhost:5000
This project is licensed under the MIT License - see the LICENSE file for details.