# flask vs fastapi — codebase comparison

> Canonical page: https://codevetter.com/unpack/compare/flask-vs-fastapi

# flask vs fastapi — codebase comparison

Flask's WSGI microframework plus extension ecosystem vs FastAPI's ASGI + type-annotation-driven API surface.

| | pallets/flask | fastapi/fastapi |
|---|---|---|
| Scanned commit | d73fa1c (2026-09-08) | 50113da (2026-09-01) |
| Files | 230 | 2950 |
| Primary source root | src | fastapi |

## flask

Flask is the Pallets WSGI web framework — a thin, opinion-light composition layer over Werkzeug (routing, request/response, dev server), Jinja (templating), itsdangerous (signed session cookies), Click (CLI) and Blinker (signals), distributed as the `flask` package plus a `flask` console script. This checkout is the unreleased 3.2.0.dev line on `main`, whose headline change is the merger of `RequestContext` into a single `AppContext`: one context object now carries app, `g`, request, session and URL adapter, is pushed once per request and per CLI command, and is threaded explicitly as a `ctx` first argument through `dispatch_request`, `full_dispatch_request`, `finalize_request`, `preprocess_request`, `process_response` and the teardown methods. The codebase is deliberately split into a sans-IO core (`src/flask/sansio/`) that alternative implementations such as Quart reuse, and IO-bound subclasses (`app.py`, `blueprints.py`) that add WSGI, Click groups and file serving. It targets Python 3.10+, is fully typed (`py.typed`, strict mypy + pyright), and ships its own tutorial, JavaScript and Celery example applications.

## fastapi

This is the FastAPI framework source repository at version 0.141.1 — a Pydantic v2-only, Starlette-based ASGI web framework whose distinguishing trick is deriving request parsing, validation, serialization and an OpenAPI 3.1 schema from ordinary Python type hints on endpoint functions. This tree is notably ahead of the classic FastAPI architecture: `include_router()` no longer flattens child routes into the parent but stores an `_IncludedRouter` wrapper resolved at match time, the package ships first-class Server-Sent Events (`fastapi/sse.py`) and JSON-Lines streaming, a `app.frontend()` / `router.frontend()` low-priority static-SPA router, and a bundled agent skill at `fastapi/.agents/skills/fastapi/SKILL.md`. The repo is overwhelmingly documentation and tests: 1692 Markdown files across 13 translated locales, 594 test files, and 464 runnable tutorial sources in `docs_src/` that the test suite executes directly. Its audience is Python API developers, and the repo itself enforces 100% line coverage, strict mypy, ty, and Ruff on every push.

Full evidence: https://codevetter.com/unpack/flask · https://codevetter.com/unpack/fastapi

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
