Chapter 2: Understanding the Python Web Stack
ASP.NET Core applications run through Kestrel and an HTTP middleware pipeline. Python has two major web server interfaces:
- WSGI: older synchronous interface used by Flask and classic Django deployments.
- ASGI: modern async-capable interface used by FastAPI, Starlette, Django async features, and websockets.
FastAPI is an ASGI app. Uvicorn receives HTTP traffic, converts it into ASGI events, and passes those events to FastAPI. FastAPI delegates much of the low-level web behavior to Starlette.
Mental model:
| ASP.NET Core | Python/FastAPI |
|---|---|
| Kestrel | Uvicorn, Granian, Hypercorn |
WebApplication | FastAPI app object |
| Middleware pipeline | ASGI middleware stack |
| Minimal API endpoint | path operation function |
| Controllers | APIRouter modules |
| Model binding | type hints plus Pydantic |
IConfiguration | settings class and environment variables |
| DI container | FastAPI dependencies plus manual composition |
Python's ecosystem is less centralized than .NET. That means fewer official one-size-fits-all answers, but also less framework gravity. Your production skill is knowing which choices to standardize inside your own project.