Update gitignore, combined docker for frotnend and api

This commit is contained in:
pratik
2025-10-16 13:38:11 -05:00
parent 2584e92af2
commit 122e3f2edc
16 changed files with 18 additions and 1533 deletions

View File

@@ -1,4 +1,4 @@
from fastapi import FastAPI
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
@@ -39,10 +39,8 @@ app.add_middleware(
app.include_router(artifacts_router)
app.include_router(seed_router)
# Mount static files
# Static directory setup
static_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "static")
if os.path.exists(static_dir):
app.mount("/static", StaticFiles(directory=static_dir), name="static")
@app.on_event("startup")
@@ -87,15 +85,13 @@ async def ui_root():
# Catch-all route for Angular SPA routing - must be last
@app.get("/{full_path:path}")
async def serve_spa(full_path: str):
"""Serve Angular SPA for all non-API routes"""
# If it's an API route, it should have been handled by routers above
# If it's a static file request, try to serve it
if full_path.startswith("static/"):
file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), full_path)
if os.path.exists(file_path):
return FileResponse(file_path)
"""Serve Angular SPA static files and handle client-side routing"""
# Try to serve static file first (JS, CSS, images, etc.)
file_path = os.path.join(static_dir, full_path)
if os.path.exists(file_path) and os.path.isfile(file_path):
return FileResponse(file_path)
# For all other routes (Angular routes), serve index.html
# For all other routes (Angular client-side routes), serve index.html
index_path = os.path.join(static_dir, "index.html")
if os.path.exists(index_path):
return FileResponse(index_path)