docs/examples/onboarding/fastapi/form_data.py
raw| 1 | from typing import Annotated |
| 2 | |
| 3 | from litestar import Litestar, post |
| 4 | from litestar.enums import RequestEncodingType |
| 5 | from litestar.params import Body |
| 6 | |
| 7 | |
| 8 | @post("/login") |
| 9 | async def login( |
| 10 | data: Annotated[dict[str, str], Body(media_type=RequestEncodingType.URL_ENCODED)], |
| 11 | ) -> dict[str, str]: |
| 12 | return {"user": data["username"]} |
| 13 | |
| 14 | |
| 15 | app = Litestar(route_handlers=[login]) |