TER/ter/routes.py
2023-11-07 08:40:43 +01:00

23 lines
534 B
Python

from fastapi import APIRouter, Request
from jinja2_fragments.fastapi import Jinja2Blocks
from ter.config import Settings
from ter.helpers import connect_db
settings = Settings()
router = APIRouter()
templates = Jinja2Blocks(settings.TEMPLATE_DIR)
@router.get("/")
def index(request: Request):
"""Home page."""
with connect_db() as db:
agencies = db.execute("SELECT * FROM agency").fetchall()
context = {"request": request, "agencies": agencies}
return templates.TemplateResponse("index.html", context)