from pathlib import Path
from litestar.response import File
from litestar import Litestar, get
from litestar.static_files import create_static_files_router
@get("/")
async def start() -> str:
return "home"
@get("/photo")
async def photo() -> File:
return File(
path=app.route_reverse("static", file_path="amd.jpg"),
content_disposition_type="inline",
)
app = Litestar(
route_handlers=[
start, photo,
create_static_files_router("/static", [Path(__name__).resolve().parent / "static"])
],
debug=True,
)
.
├── app.py
└── static
└── amd.jpg
Why I get 500: /static/amd.jpg does not exist