Debian Codegraph @

docs/examples/onboarding/django/exceptions.py

raw
1 from litestar import Litestar, get
2 from litestar.exceptions import NotFoundException
3 from litestar.params import FromPath
4
5
6 @get("/items/{item_id:int}")
7 async def get_item(item_id: FromPath[int]) -> dict[str, int]:
8 if item_id != 1:
9 raise NotFoundException(detail=f"item {item_id} does not exist")
10 return {"id": item_id}
11
12
13 app = Litestar(route_handlers=[get_item])