from pathlib import Path

from litestar import Litestar, get
from litestar.contrib.jinja import JinjaTemplateEngine
from litestar.response import Template
from litestar.template.config import TemplateConfig

from asgi_autoreload import AutoreloadMiddleware


@get("/")
async def index() -> Template:
    return Template("index.html")


@get("/about")
async def about() -> Template:
    return Template("about.html")


_app = Litestar(
    route_handlers=[index, about],
    template_config=TemplateConfig(
        directory=Path("templates"),
        engine=JinjaTemplateEngine,
    ),
)

app = AutoreloadMiddleware(_app)
