Building APIs with FastAPI · 12-day planAll days
Day 8 of 12 25 minAPIRouterSettingsLifespan
Organise a growing API into a clean project. Split endpoints into APIRouter modules with prefixes and tags, read configuration from environment variables with a settings object, run startup and shutdown code with lifespan, version your API, and tidy the docs.
By the end of today you can
- Split endpoints into modules with APIRouter, prefixes and tags
- Lay out a project in files and folders
- Read configuration from environment variables with a settings object
- Run setup and teardown with a lifespan function
- Version an API and improve its documentation
What's inside
- 5 sections
- 2 diagrams and mind maps
- 3 code examples you can run
- 5-question quiz
- 1Routers
- 2A project layout
- 3Settings from the environment
- 4Startup and shutdown: lifespan
- 5Nicer documentation
Sign in free to read this lesson
Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.
Sign in free