Skip to content

AKJilani/API_Using_Flask_Framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flask CRUD API with Authentication and Swagger Documentation

This project is a professional Flask REST API that provides full CRUD operations for items, along with user registration, user login, password hashing, HTTP Basic Authentication, and a Swagger-based API documentation.


πŸš€ Features

  • βœ… RESTful CRUD API for managing items
  • βœ… User registration and login endpoints
  • βœ… Password hashing using Werkzeug
  • βœ… HTTP Basic Authentication for secured endpoints
  • βœ… SQLite database using SQLAlchemy ORM
  • βœ… Marshmallow serialization
  • βœ… Swagger UI documentation (/docs)
  • βœ… Clean and professional project structure
  • βœ… Ready for deployment

πŸ› οΈ Technology Stack

  • Python 3.x
  • Flask
  • SQLAlchemy
  • Marshmallow
  • Flask-HTTPAuth
  • Flask-Swagger-UI

πŸ“ Project Structure

flask_api_project/ β”œβ”€β”€ app/ β”‚ β”œβ”€β”€ init.py β”‚ β”œβ”€β”€ auth.py β”‚ β”œβ”€β”€ auth_routes.py β”‚ β”œβ”€β”€ database.py β”‚ β”œβ”€β”€ models.py β”‚ β”œβ”€β”€ routes.py β”‚ β”œβ”€β”€ schemas.py β”œβ”€β”€ instance/ β”‚ └── app.db β”œβ”€β”€ static/ β”‚ └── swagger.yaml β”œβ”€β”€ .gitignore β”œβ”€β”€ README.md β”œβ”€β”€ requirements.txt β”œβ”€β”€ run.py └── venvAPIFlask/


πŸ“¦ Installation

  1. Clone the repository:
git clone https://github.com/AKJilani/API_Using_Flask_Framework.git
cd API_Using_Flask_Framework
Create virtual environment:

bash
Copy
Edit
python -m venv venvAPIFlask
Activate virtual environment:

On Windows:

bash
Copy
Edit
venvAPIFlask\Scripts\activate
On Linux/macOS:

bash
Copy
Edit
source venvAPIFlask/bin/activate
Install dependencies:

bash
Copy
Edit
pip install -r requirements.txt
βš™οΈ Running the Project
bash
Copy
Edit
python run.py
The API will run at:

arduino
Copy
Edit
http://localhost:5000
Swagger UI (API Documentation) will be available at:

bash
Copy
Edit
http://localhost:5000/docs
πŸ” Authentication System
Register User: POST /register

Login User: POST /login

Protected Endpoints: All /items routes require HTTP Basic Authentication.

You can use registered users or the static admin user:

Username: admin

Password: password123

πŸ“š API Endpoints
Method	Endpoint	Description	Auth Required
POST	/register	Register new user	❌
POST	/login	Login existing user	❌
GET	/items	List all items	βœ…
POST	/items	Create new item	βœ…
GET	/items/<item_id>	Get single item	βœ…
PUT	/items/<item_id>	Update item	βœ…
DELETE	/items/<item_id>	Delete item	βœ…

πŸ“„ Swagger API Documentation
Path: http://localhost:5000/docs

Uses static YAML file located at: static/swagger.yaml

You can test all APIs directly from the Swagger UI.

πŸ“‹ License
This project is open-source and free to use.

πŸ‘€ Developed By
Abdul Kader Jilani
Freelancer | Python & Web Developer

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages