This commit is contained in:
LASTA_DEV01\lasta
2026-05-19 20:31:52 +09:00
parent 00407e7a08
commit e260e5f218
104 changed files with 12898 additions and 1709 deletions

View File

@@ -5,7 +5,6 @@ from pathlib import Path
from fastapi import FastAPI, Request
from fastapi.responses import FileResponse, JSONResponse
from fastapi.staticfiles import StaticFiles
from crawler_platform.app.api.routes import register_routes
from crawler_platform.app.core.database.session import init_db
@@ -23,8 +22,18 @@ register_routes(app, DATABASE_URL)
def _handle_key_error(_request: Request, exc: KeyError) -> JSONResponse:
return JSONResponse(status_code=404, content={"detail": str(exc.args[0]) if exc.args else "not found"})
if STATIC_DIR.exists():
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
@app.get("/static/{asset_path:path}", include_in_schema=False)
def static_or_spa(asset_path: str):
static_root = STATIC_DIR.resolve()
target = (static_root / asset_path).resolve()
try:
target.relative_to(static_root)
except ValueError:
return JSONResponse(status_code=404, content={"detail": "not found"})
if target.is_file():
return FileResponse(target)
return FileResponse(STATIC_DIR / "index.html")
@app.get("/", include_in_schema=False)