INNER CODE UNIT · Python

_resolve_frontend_dist

ohdearquant/lionagi · lionagi/studio/app.py:315

def _resolve_frontend_dist() -> Path | None:
    """Return the dist/ directory to serve, or None if absent (reads
    LIONAGI_STUDIO_FRONTEND_DIST; unset means API-only mode)."""
    env_override = os.environ.get("LIONAGI_STUDIO_FRONTEND_DIST")
    if not env_override:
        return None
    p = Path(env_override)
    return p if (p / "index.html").exists() else None


def _mount_spa(application: FastAPI, dist: Path) -> None:
    """Mount static assets and register an SPA 404 fallback. Uses a 404
    exception handler, not a catch-all route (which would intercept
    /api/shows before FastAPI's trailing-slash redirect fires).
    """
    assets_dir = dist / "assets"
    if assets_dir.is_dir():
        application.mount("/assets", StaticFiles(directory=str(assets_dir)), name="spa-assets")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…