formatting

This commit is contained in:
John Lancaster
2026-06-19 01:29:05 -05:00
parent 964cd6f76d
commit 3347443ca9
27 changed files with 275 additions and 238 deletions
@@ -1,6 +1,8 @@
# FastAPI Best Practices
Source: https://fastapi.tiangolo.com/deployment/ | https://fastapi.tiangolo.com/advanced/events/
!!! info "Primary sources"
- [FastAPI deployment](https://fastapi.tiangolo.com/deployment/)
- [FastAPI lifespan events](https://fastapi.tiangolo.com/advanced/events/)
---
@@ -44,7 +46,8 @@ def create_app(settings: Settings | None = None) -> FastAPI:
app = create_app()
```
**Never use `@app.on_event("startup")` / `@app.on_event("shutdown")`** — these are deprecated. The `asynccontextmanager` lifespan is the canonical approach since FastAPI 0.95.
!!! warning "Prefer lifespan handlers"
Never use `@app.on_event("startup")` / `@app.on_event("shutdown")`. These are deprecated. The `asynccontextmanager` lifespan is the canonical approach since FastAPI 0.95.
---