1aea0f558e
- cookbook.js: Fit-Ampel (gruen/gelb/rot) + Legende + Klartext-Urteile, sauberes Modal. - server.js: heikle Aktionen mit confirmModal/promptModal (Klartext-Konsequenz), Konsole im neuen Stil, Begriffe uebersetzt. - models.js: Tabelle re-skinnt (Capability-Tags statt Emoji, --blue raus), Entladen mit Bestaetigung, Konfig-Modal vereinheitlicht. - jobs.js (Aktivitaet): Metrik-Kacheln + Klartext-Verlaeufe. - guides.js: Kopf + Intro, Integrations-URL aus Browser-Host abgeleitet. - index.html: Mountpunkte fuer Modelle-/Aktivitaets-Kopf. - app.py: no-cache-Middleware fuer /static (UI-Aenderungen wirken sofort nach rsync, kein Stale-JS mehr). - base.css: Sidebar bei schmalem Viewport icon-only (Label-Ueberlappung gefixt). Verifiziert: alle 6 Panels mounten fehlerfrei (0 Konsolenfehler), Fit-Ampel rechnet live. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""
|
|
Mission Control - eine schlanke Steuerzentrale fuer einen lokalen llama-swap Stack.
|
|
|
|
Dieser Einstieg haelt nur noch das Geruest zusammen: er baut die FastAPI-App,
|
|
haengt die Router ein und liefert das statische UI aus. Die eigentliche Logik
|
|
liegt nach Concern getrennt in:
|
|
- config.py Env-Vars / Konstanten
|
|
- auth.py optionale Token-Auth
|
|
- jobengine.py Hintergrund-Jobs mit Live-Log
|
|
- llamaswap.py Reden mit llama-swap + config.yaml lesen/schreiben
|
|
- routers/* ein Router je Bereich (models, jobs, maintenance, ...)
|
|
|
|
Bewusst KISS: kein Build-Schritt, kein Framework ueber FastAPI hinaus, keine DB.
|
|
Neue Bereiche kommen als routers/<bereich>.py + static/js/panels/<bereich>.js dazu.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from fastapi import FastAPI, HTTPException
|
|
from fastapi.responses import FileResponse, JSONResponse
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from routers import jobs, maintenance, models, system, cookbook
|
|
|
|
app = FastAPI(title="Mission Control")
|
|
|
|
|
|
@app.middleware("http")
|
|
async def _no_cache_static(request, call_next):
|
|
"""UI + statische Module immer revalidieren lassen (304 wenn unveraendert),
|
|
damit Aenderungen nach einem rsync sofort wirken und kein Stale-JS haengen bleibt."""
|
|
response = await call_next(request)
|
|
path = request.url.path
|
|
if path == "/" or path.startswith("/static"):
|
|
response.headers["Cache-Control"] = "no-cache"
|
|
return response
|
|
|
|
|
|
app.include_router(models.router)
|
|
app.include_router(jobs.router)
|
|
app.include_router(maintenance.router)
|
|
app.include_router(system.router)
|
|
app.include_router(cookbook.router)
|
|
|
|
_STATIC = Path(__file__).parent / "static"
|
|
|
|
|
|
@app.get("/")
|
|
def index():
|
|
return FileResponse(_STATIC / "index.html")
|
|
|
|
|
|
app.mount("/static", StaticFiles(directory=_STATIC), name="static")
|
|
|
|
|
|
@app.exception_handler(HTTPException)
|
|
def _http_exc(_req, exc: HTTPException):
|
|
return JSONResponse(status_code=exc.status_code, content={"error": exc.detail})
|