Serve the rulebook as a static HTML page from FastAPI
Replace the SPA Rules route with a self-contained src/pirats/rules.html served at GET /rules (registered before the SPA mount, included in package data for the Nix build). Plain anchor links replace the scrollIntoView workaround since there's no hash router to fight. The corner Rules link and splash-page link now point at /rules, and the Vite dev server proxies /rules to the backend like /api. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import Optional
|
||||
from fastapi import FastAPI, Form, Depends, HTTPException, APIRouter
|
||||
from fastapi.responses import FileResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from sqlmodel import Session
|
||||
import uvicorn
|
||||
@@ -105,6 +106,11 @@ api.include_router(admin_router)
|
||||
# Mount API at /api
|
||||
app.include_router(api, prefix="/api")
|
||||
|
||||
# Static rulebook page (registered before the SPA mount so it takes precedence)
|
||||
@app.get("/rules", include_in_schema=False)
|
||||
def rules_page():
|
||||
return FileResponse(BASE_DIR / "rules.html", media_type="text/html")
|
||||
|
||||
# Mount SPA
|
||||
static_dir = BASE_DIR / "static"
|
||||
if os.path.exists(static_dir):
|
||||
|
||||
Reference in New Issue
Block a user