Flask is a lightweight Python WSGI web framework (Werkzeug + Jinja2) widely used for REST APIs, ML model-serving microservices, internal tools, and webhook receivers. This section covers Flask end-to-end: architectural overview, benefits and when to reach for it, building REST APIs with validation and auth, runnable sample code for CRUD and ML serving, and production deployment with gunicorn, nginx, Docker, and Kubernetes.
The five pages form a path. Start with the Overview for the WSGI model and the request lifecycle, and use Benefits to decide whether Flask is the right tool. Building REST APIs and Sample Code cover building the service, and Production Deployment covers running it behind gunicorn and nginx, in containers and on Kubernetes.
| Framework | Model | Choose when |
|---|---|---|
| Flask | Synchronous WSGI, minimal core plus extensions | Small to medium APIs, ML model serving, internal tools, maximum flexibility |
| FastAPI | ASGI, async, type-hint validation, automatic OpenAPI | High-concurrency I/O-bound APIs, schema-first contracts |
| Django | Batteries included: ORM, admin, auth | Full web applications with a relational data model |