Debian Codegraph @

docs/examples/onboarding/django/sync_handler.py

raw
1 import time
2
3 from litestar import Litestar, get
4
5
6 @get("/", sync_to_thread=True)
7 def slow_handler() -> dict[str, str]:
8 time.sleep(0.01)
9 return {"hello": "world"}
10
11
12 @get("/fast", sync_to_thread=False)
13 def fast_handler() -> dict[str, str]:
14 return {"hello": "world"}
15
16
17 app = Litestar(route_handlers=[slow_handler, fast_handler])