
Hybrid App is a full-stack web application that combines FastAPI and Flask in a single process. FastAPI handles the REST API layer while Flask + Jinja2 powers the server-rendered frontend. Both frameworks coexist thanks to a2wsgi, which mounts the Flask WSGI app onto the FastAPI instance.
FastAPI (root app)
├── /api/items → REST API (FastAPI + SQLAlchemy)
└── / → Web UI (Flask + Jinja2 via WSGI middleware)
| Layer | Technology |
|---|---|
| API | FastAPI, Pydantic, fastapi-pagination |
| Web UI | Flask, Jinja2 |
| Database | SQLAlchemy (SQLite by default) |
| Bridge | a2wsgi (WSGI ↔ ASGI) |
| Server | Uvicorn |
/api/items) with full CRUD, pagination, and filtering by name and price range/ and /aboutpip install -r requirements.txt
python run.py
The app will be available at http://localhost:8000.
| Endpoint | Description |
|---|---|
GET / |
Flask home page |
GET /about |
Flask about page |
GET /api/items |
List items (paginated) |
POST /api/items |
Create a new item |
GET /api/items/{id} |
Get item by ID |
PUT /api/items/{id} |
Update an item |
DELETE /api/items/{id} |
Delete an item |
GET /docs |
Interactive API docs (Swagger UI) |
app/
├── main.py # FastAPI app + Flask mount
├── config.py # App configuration
├── db.py # SQLAlchemy engine and session
├── models.py # ORM models
├── api/
│ └── items.py # Items REST API router
└── web/
├── routes.py # Flask blueprints and routes
├── static/ # CSS assets
└── templates/ # Jinja2 HTML templates