from fastapi import APIRouter, Request
from fastapi.templating import Jinja2Templates

from src.webapps.admin import route_admin
from src.webapps.auth import route_login
from src.webapps.comic import route_comics, route_worktype, route_artists
from src.webapps.media import route_media, route_videos

templates = Jinja2Templates(directory="src/templates")

api_router = APIRouter()
api_router.include_router(route_comics.router)
api_router.include_router(route_artists.router)
api_router.include_router(route_worktype.router)
api_router.include_router(route_media.router)
api_router.include_router(route_videos.router)
api_router.include_router(route_login.router)
api_router.include_router(route_admin.router)

@api_router.get("/")
def home(request: Request, msg: str | None = None):
    return templates.TemplateResponse("index.html", {"request": request, "msg": msg})
