dipan004 commited on
Commit
48c328a
·
verified ·
1 Parent(s): 837f70f

Update backend/main.py

Browse files
Files changed (1) hide show
  1. backend/main.py +19 -1
backend/main.py CHANGED
@@ -112,15 +112,33 @@ async def health():
112
  }
113
 
114
 
 
 
 
 
115
  # ---------------------------------------------------------------------------
116
  # Frontend static files or root redirect
117
  # ---------------------------------------------------------------------------
118
 
119
  from fastapi.staticfiles import StaticFiles
 
120
 
121
  _frontend_dist = Path(_PROJECT_ROOT) / "dashboard" / "dist"
 
122
  if _frontend_dist.is_dir():
123
- app.mount("/", StaticFiles(directory=str(_frontend_dist), html=True), name="dashboard")
 
 
 
 
 
 
 
 
 
 
 
 
124
  else:
125
  @app.get("/", include_in_schema=False)
126
  async def root():
 
112
  }
113
 
114
 
115
+ # ---------------------------------------------------------------------------
116
+ # Frontend static files or root redirect
117
+ # ---------------------------------------------------------------------------
118
+
119
  # ---------------------------------------------------------------------------
120
  # Frontend static files or root redirect
121
  # ---------------------------------------------------------------------------
122
 
123
  from fastapi.staticfiles import StaticFiles
124
+ from fastapi.responses import FileResponse
125
 
126
  _frontend_dist = Path(_PROJECT_ROOT) / "dashboard" / "dist"
127
+
128
  if _frontend_dist.is_dir():
129
+
130
+ # Serve Vite assets
131
+ app.mount(
132
+ "/assets",
133
+ StaticFiles(directory=str(_frontend_dist / "assets")),
134
+ name="assets"
135
+ )
136
+
137
+ # Serve frontend index
138
+ @app.get("/", include_in_schema=False)
139
+ async def root():
140
+ return FileResponse(_frontend_dist / "index.html")
141
+
142
  else:
143
  @app.get("/", include_in_schema=False)
144
  async def root():