Skip to content

meez-111/pyblogAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyBlog API: A RESTful Blog Backend


live Demo on Render

Render: PyblogAPI


Project Overview

PyBlog API is a robust, production-ready backend for a blog application, built with Django and Django REST Framework (DRF). This project provides a comprehensive set of RESTful endpoints to manage blog posts, user authentication, and data persistence. Designed as a decoupled backend, it allows any frontend application (web, mobile, or desktop) to consume its data via API calls.

This project showcases proficiency in building a complete RESTful API, secure user authentication, data serialization, and professional deployment to a cloud platform like Render.

Key Features

  • User Authentication: Secure user registration, login, and token generation.
  • Post Management (CRUD): Full Create, Read, Update, and Delete functionality for blog posts.
  • Authorization: Ensures users can only modify or delete their own posts.
  • Image Uploads: Handles and serves images associated with blog posts.

Technology Stack

  • Backend: Python, Django, Django REST Framework (DRF), Gunicorn, PostgreSQL
  • Deployment & Tools: Render, dj-database-url, WhiteNoise, Git

API Endpoints

All endpoints are designed to be intuitive and easy to use.

Endpoint Method Description
/register_user/ POST Registers a new user.
/token/ POST Exchanges user credentials for a new access and refresh token.
/refresh_token/ POST Refreshes the access token using a valid refresh token.
/create_blog/ POST Creates a new blog post. Requires user authentication.
/update_user_profile/ PUT Updates the profile of the authenticated user.
/blogs_list/ GET Retrieves a list of all published blog posts.
/user_blogs_list/ GET Retrieves a list of blog posts for the authenticated user.
/update_blog/<int:blog_id>/ PUT Updates a specific blog post. Requires authentication and author ownership.
/delete_blog/<int:blog_id>/ DELETE Deletes a specific blog post. Requires authentication and author ownership.

Installation and Local Setup

To get a local copy of the project up and running, follow these steps.

  1. Clone the Repository:

    git clone https://github.com/meez-111/pyblogAPI.git
    cd pyblogAPI
  2. Create and Activate a Virtual Environment:

    python -m venv venv
    source venv/bin/activate
  3. Install Dependencies:

    pip install -r requirements.txt
  4. Database Migrations:

    python manage.py makemigrations
    python manage.py migrate
  5. Create a Superuser (Optional):

    python manage.py createsuperuser
  6. Run the Development Server:

    python manage.py runserver

    The API will be available at http://127.0.0.1:8000/.


Deployment

This project is deployed on Render using a PostgreSQL database.

  • Build Script: A build.sh script automates the build process, including running migrations and collecting static files.
  • Start Command: gunicorn pyblogapi.wsgi
  • A persistent disk is configured on Render to ensure user-uploaded images remain available across deployments.

Author

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published