| Task | Command / Code |
| Install | pip install fastapi uvicorn |
| Run dev server | uvicorn main:app --reload |
| Run production | gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker |
| Create app | app = FastAPI() |
| GET endpoint | @app.get("/path") |
| POST endpoint | @app.post("/path") |
| Path param | def func(item_id: int) |
| Query param | def func(q: str = None) |
| Request body | def func(item: Item) |
| Form data | def func(name: str = Form(...)) |
| File upload | def func(file: UploadFile = File(...)) |
| Dependency | def func(db: Session = Depends(get_db)) |
| Response model | @app.get("/path", response_model=ItemOut) |
| Status code | @app.post("/path", status_code=201) |
| Docs URL | /docs (Swagger), /redoc (ReDoc) |
| Mount static | app.mount("/static", StaticFiles(...)) |
| CORS | app.add_middleware(CORSMiddleware, ...) |