Skip to content

samfr7/blogging_platform_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blogging Platform API

A RESTful API built with Flask and MySQL for managing blog posts with categories and tags.

Features

  • CRUD operations for blog posts
  • Category management
  • Tag management
  • Database transaction handling
  • Error handling and validation

Technologies Used

  • Python 3.x
  • Flask
  • MySQL
  • python-dotenv

Setup

  1. Clone the repository
  2. Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install flask mysql-connector-python python-dotenv
  1. Create a .env file with the following variables:
DB_HOST=your_host
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=blogging_platform
  1. Initialize the database:
python create_db.py
mysql -u your_username -p blogging_platform < init.sql

API Endpoints

Posts

  • GET /posts - Get all posts
  • POST /posts - Create a new post
  • GET /posts/<id> - Get a specific post
  • PUT /posts/<id> - Update a specific post
  • DELETE /posts/<id> - Delete a specific post

Request Body Format (POST/PUT)

{
    "title": "Post Title",
    "content": "Post Content",
    "category": "Technology",
    "tags": ["Coding", "Tech News"]
}

Database Schema

  • categories - Stores blog categories
  • tags - Stores available tags
  • posts - Stores blog posts
  • post_tags - Junction table for post-tag relationships

Running the Application

python app.py

The server will start on http://localhost:5000

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages