Fastapi Tutorial Pdf -
The docs live in the docs/en/ folder. They are Markdown files.
pip install mkdocs-material mkdocs-exclude
pip install fastapi uvicorn[standard]
| Concept | Code Snippet |
|---------|---------------|
| Basic app | app = FastAPI() |
| GET | @app.get("/path") |
| POST | @app.post("/path") |
| Path param | def fn(item_id: int) |
| Query param | def fn(q: str = None) |
| Body | def fn(item: Item) |
| Depends | def fn(db = Depends(get_db)) |
| Exception | raise HTTPException(404, "msg") |
| Response model | @app.get("/", response_model=Item) |
| Docs URL | /docs or /redoc | fastapi tutorial pdf