Debian Codegraph @

docs/examples/onboarding/flask/url_for.py

raw
1 from litestar import Litestar, Request, get
2 from litestar.response import Redirect
3
4
5 @get("/", name="index", sync_to_thread=False)
6 def index() -> str:
7 return "hello"
8
9
10 @get("/hello", sync_to_thread=False)
11 def hello(request: Request) -> Redirect:
12 return Redirect(path=request.url_for("index"))
13
14
15 app = Litestar(route_handlers=[index, hello])