1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
from typing import Annotated
from fastapi import FastAPI, Request, Depends
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from starlette.templating import Jinja2Templates
from app.utils import get_avatar_urls, get_client_geo
from app.logging import logger
templates = Jinja2Templates(directory="templates")
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
@app.get("/", response_class=HTMLResponse)
async def index(
request: Request,
client_geo: Annotated[dict, Depends(get_client_geo)],
avatar_urls: Annotated[list[str], Depends(get_avatar_urls)],
):
logger.info(str(dict(request.headers)))
return templates.TemplateResponse(
"index.html",
{"request": request, "client_geo": client_geo, "avatar_urls": avatar_urls},
)
|