feat: Add initial backend application and update Dockerfile for its setup.
This commit is contained in:
@@ -9,6 +9,9 @@ from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.responses import FileResponse
|
||||
import os
|
||||
|
||||
from app.config import settings
|
||||
from app.database import init_db
|
||||
@@ -62,6 +65,23 @@ app.include_router(logs.router)
|
||||
app.include_router(workflows.router)
|
||||
app.include_router(config.router)
|
||||
|
||||
# ─── Static Files ─────────────────────────────────────────────────────────────
|
||||
|
||||
if os.path.exists("static"):
|
||||
app.mount("/assets", StaticFiles(directory="static/assets"), name="assets")
|
||||
|
||||
@app.get("/{full_path:path}")
|
||||
async def serve_spa(full_path: str):
|
||||
# API requests should already be handled by routers
|
||||
# If not an API request, serve index.html
|
||||
if full_path.startswith("api/") or full_path.startswith("ws/"):
|
||||
return None # Should not happen due to router order
|
||||
|
||||
index_path = os.path.join("static", "index.html")
|
||||
if os.path.exists(index_path):
|
||||
return FileResponse(index_path)
|
||||
return {"detail": "Frontend not found"}
|
||||
|
||||
|
||||
# ─── WebSocket ─────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user