Concepts 🚀 Project 🧮 Labs
📚 Learn / Web & FastAPI

🌐 Web & FastAPI

How HTTP requests become HTML pages and JSON responses.

8 concepts
1
Routes & path operations
@router.get('/path') registers a function as the handler for GET requests to /path.
›
2
The Request object
request.headers, request.cookies, request.url, request.query_params — everything the client sent.
›
3
Pydantic request bodies
Define a Pydantic model; FastAPI validates the JSON body, raises 422 if invalid.
›
4
Jinja2 templates
Server-side HTML rendering with {% extends %}, {% block %}, {{ var }}.
›
5
Middleware
Code that runs before/after every request. Used for timing, security headers, CORS.
›
6
WebSockets
Bidirectional, persistent connection. Used for live leaderboard updates.
›
7
Dependency injection (Depends)
Share setup logic across routes. get_db is a dep that opens a DB session per request.
›
8
App lifespan (startup/shutdown)
Run code when the app starts and stops. Used to init the DB and seed data.
›