Spaces:
Running
Running
Download server/app.py from iparaco/Virtual-LPU: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/iparaco/Virtual-LPU/resolve/refs%2Fpr%2F2/server/app.py
- Command line
-
hf download hf://spaces/iparaco/Virtual-LPU@refs/pr/2/server/app.py
-
curl -L -o app.py https://huggingface.co/spaces/iparaco/Virtual-LPU/resolve/refs%2Fpr%2F2/server/app.py
1.48 kB
| """LPU AI Accelerator — FastAPI control plane (delivered V7.1 shape).""" | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| from typing import Optional | |
| from fastapi import FastAPI | |
| from fastapi.responses import FileResponse | |
| from lpu.version import __version__ as LPU_VERSION | |
| _created = False | |
| def _find_dashboard() -> Optional[Path]: | |
| candidates = [Path(__file__).resolve().parent.parent / "frontend" | |
| / "dashboard.html"] | |
| meipass = getattr(sys, "_MEIPASS", None) | |
| if meipass: | |
| m = Path(meipass) | |
| candidates += [m / "frontend" / "dashboard.html", | |
| m.parent / "frontend" / "dashboard.html"] | |
| for cand in candidates: | |
| if cand.exists(): | |
| return cand | |
| return None | |
| def create_app(config: dict | None = None) -> FastAPI: | |
| global _created | |
| cfg = config or {} | |
| app = FastAPI(title="LPU AI Accelerator V7", version=LPU_VERSION) | |
| async def _startup() -> None: | |
| pass | |
| async def dashboard(): | |
| dash = _find_dashboard() | |
| if dash is None: | |
| return {"error": "dashboard.html missing"} | |
| return FileResponse(dash, media_type="text/html") | |
| async def status(): | |
| return { | |
| "runtime_version": LPU_VERSION, | |
| "accelerator_status": "running" if cfg.get("accelerator", {}).get("autostart") else "stopped", | |
| } | |
| return app | |