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