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

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages