This is the initial push of the outline of the life dashboard
This commit is contained in:
28
backend/app/main.py
Normal file
28
backend/app/main.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from starlette.responses import FileResponse
|
||||
|
||||
from app.routers import auth, finance, weight, workout
|
||||
|
||||
app = FastAPI(title="Life Dashboard API")
|
||||
|
||||
# API routers
|
||||
app.include_router(auth.router)
|
||||
app.include_router(weight.router)
|
||||
app.include_router(workout.router)
|
||||
app.include_router(finance.router)
|
||||
|
||||
# Serve React SPA static files
|
||||
STATIC_DIR = Path(__file__).resolve().parent.parent / "static"
|
||||
|
||||
if STATIC_DIR.exists():
|
||||
app.mount("/assets", StaticFiles(directory=STATIC_DIR / "assets"), name="assets")
|
||||
|
||||
@app.get("/{full_path:path}")
|
||||
async def serve_spa(full_path: str):
|
||||
file_path = STATIC_DIR / full_path
|
||||
if file_path.is_file():
|
||||
return FileResponse(file_path)
|
||||
return FileResponse(STATIC_DIR / "index.html")
|
||||
Reference in New Issue
Block a user