📄 login_router.py 1,133 bytes Yesterday 01:29 📋 Raw

"""RTSport Login Page Router.

Serves the static login page at GET /rtsport/login.
Reads the template file from the shared frontend directory at request time.
"""

from pathlib import Path

from fastapi import APIRouter
from fastapi.responses import HTMLResponse

router = APIRouter(prefix="/rtsport", tags=["rtsport-login"])

Resolve the shared template via the current symlink

_TEMPLATE_DIR = Path("/home/hoffmann_admin/.openclaw/shared/current/frontend/templates")
_LOGIN_HTML = _TEMPLATE_DIR / "login.html"

@router.get("/login", response_class=HTMLResponse)
async def serve_login_page() -> HTMLResponse:
"""Serve the RTSport login page.

Reads the HTML template from disk on each request, allowing
the frontend team to update the template without restarting the server.
"""
try:
    html = _LOGIN_HTML.read_text(encoding="utf-8")
except FileNotFoundError:
    return HTMLResponse(
        content="<h1>Login page not found</h1><p>The template file is missing. Please ensure the frontend build is complete.</p>",
        status_code=404,
    )
return HTMLResponse(content=html)