Spaces:
Sleeping
Sleeping
Claude Code commited on
Commit ·
7a6856a
1
Parent(s): e667222
Claude Code: Add StaticFiles mount and frontend index.html
Browse files- Import StaticFiles from fastapi.staticfiles
- Mount /frontend to serve pixel art, fonts, HTML
- Create frontend/index.html as main entry page with links
app.py
CHANGED
|
@@ -17,7 +17,8 @@ print(">>> CAIN: PORT =", os.environ.get('PORT', '7860'), flush=True)
|
|
| 17 |
# CRITICAL: Create FastAPI app at TOP LEVEL, outside any try/except
|
| 18 |
# This ensures the server ALWAYS starts, even if brain is broken
|
| 19 |
from fastapi import FastAPI, Request
|
| 20 |
-
from fastapi.responses import JSONResponse
|
|
|
|
| 21 |
from contextlib import asynccontextmanager
|
| 22 |
|
| 23 |
print(">>> CAIN: Creating FastAPI app...", flush=True)
|
|
@@ -33,6 +34,9 @@ async def lifespan(app: FastAPI):
|
|
| 33 |
|
| 34 |
app = FastAPI(title="HuggingClaw - Cain", version="0.0.1", lifespan=lifespan)
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
@app.get("/")
|
| 37 |
async def root():
|
| 38 |
"""Root endpoint - simple alive status."""
|
|
|
|
| 17 |
# CRITICAL: Create FastAPI app at TOP LEVEL, outside any try/except
|
| 18 |
# This ensures the server ALWAYS starts, even if brain is broken
|
| 19 |
from fastapi import FastAPI, Request
|
| 20 |
+
from fastapi.responses import JSONResponse, FileResponse
|
| 21 |
+
from fastapi.staticfiles import StaticFiles
|
| 22 |
from contextlib import asynccontextmanager
|
| 23 |
|
| 24 |
print(">>> CAIN: Creating FastAPI app...", flush=True)
|
|
|
|
| 34 |
|
| 35 |
app = FastAPI(title="HuggingClaw - Cain", version="0.0.1", lifespan=lifespan)
|
| 36 |
|
| 37 |
+
# Mount frontend folder for static assets (pixel art, fonts, HTML)
|
| 38 |
+
app.mount("/frontend", StaticFiles(directory="frontend"), name="frontend")
|
| 39 |
+
|
| 40 |
@app.get("/")
|
| 41 |
async def root():
|
| 42 |
"""Root endpoint - simple alive status."""
|