import os

import jinja2
from esmerald import Request, Response, get
from esmerald.responses import HTMLResponse

ENVIRONMENT = jinja2.Environment(
    loader=jinja2.FileSystemLoader(
        searchpath=os.path.join(os.path.dirname(__file__), "templates")
    )
)


@get(path="/", include_in_schema=False)
def home(request: Request) -> HTMLResponse:
    template = ENVIRONMENT.get_template("home.html.jinja")

    content = template.render(title="Piccolo + ASGI",)

    return HTMLResponse(content)
