from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from app.services.gitbucket import fetch_repos

router = APIRouter()
templates = Jinja2Templates(directory="app/templates")

@router.get("/projects", response_class=HTMLResponse)
async def projects(request: Request):
    repos = await fetch_repos()
    return templates.TemplateResponse(
        "projects.html",
        {"request": request, "repos": repos}
    )
