Week 6 · Season 2 · Face and hands
A brain on a server
You can run a small Python server, design its API, reject bad input, survive a model that says no, and prove it all works with tests.
This week
- Backends, servers, ports and localhost
- Design an API: routes, methods and REST
- Validation, schemas and structured output
- Errors, retries, timeouts and rate limits
- Tests with pytest, and which to write first
How you learn
Build the server one route at a time: write the menu of routes and their request and response shapes first, then the validation, then the model call with a timeout, retries and backoff. Write a test with a fake model before each route.
What you build
Page, your server, the model: FRIDAY's chat page calls your own FastAPI server, which checks the message, calls a free model with retries and a timeout, and returns a clean reply. The API key never leaves the server.
Stretch: Make the model call async, version the API under /v1, and read your own OpenAPI file at /openapi.json.
What you ship
Project 1: FRIDAY goes online. A chat page, your own server and database, real tools and sign-in, reachable from your phone.
- server.py with /health and /chat, checked input, and a timeout with retries
- pytest tests with a fake model that pass on GitHub, and the chat page talking to your server
Lessons
- The kitchen behind the restaurant
After this deck you can say what a frontend and a backend are, explain how a port picks the program that gets a message, say what localhost means, and solve a *connection refused* error.
- Design an API
After this deck you can design a small API: name its routes, pick the right method for each wish, follow the REST habit, describe request and response shapes, and read a FastAPI route.
- Trust nothing that arrives
After this deck you can validate everything that reaches FRIDAY's kitchen against a schema, send back a clear 422, and treat a model's reply as one more thing to check, even with structured output.
- When the other side says no
After this deck you can tell errors worth retrying from errors to fix, wait with backoff and jitter, honour Retry-After, set a timeout, and fail kindly when the model is busy.
- Prove it works
After this deck you can write tests with pytest, use FastAPI's test client to order from your kitchen without a network, swap the model for a fake, and choose which tests to write first.
- Go deeper: one cook, many pots
After this deck you can explain async (waiting without blocking), keep old pages working with versioned routes, and read the OpenAPI file FastAPI writes for you.
Labs
Python in the browser, next to the lessons.
Weekend build
- Page → your server → the model
FRIDAY gets a kitchen: your chat page calls your own server, and only your server talks to the model.
Skills you prove
- API design
- Design and build a small HTTP API that validates everything it receives
Free links for this week
Hand-picked official docs, papers and talks.
- FastAPI · docs
- FastAPI: Testing · docs
- Pydantic docs · docs
- MDN: HTTP · docs
- MDN: HTTP response status codes · docs
- FastAPI: Concurrency and async / await · docs
- OpenAPI Specification · docs
- pytest docs · docs
- Structured outputs · docs
- API errors and overloads · docs
- uv (Python project manager) · docs