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.
- β 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
- Python 3.x
- Flask
- SQLAlchemy
- Marshmallow
- Flask-HTTPAuth
- Flask-Swagger-UI
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/
- 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