Fred808 commited on
Commit
05fa183
·
verified ·
1 Parent(s): ec8cf7e

Update download_api.py

Browse files
Files changed (1) hide show
  1. download_api.py +9 -5
download_api.py CHANGED
@@ -61,15 +61,19 @@ async def startup_event():
61
 
62
  from fastapi.staticfiles import StaticFiles
63
 
64
- BASE_DIR = "."
65
 
 
66
  @app.get("/")
67
  async def root():
68
- """Serve the index.html file"""
69
- return FileResponse(os.path.join(BASE_DIR, 'index.html'))
70
 
71
- # Mount static files at a different path to avoid conflict with root route
72
- app.mount("/static", StaticFiles(directory="."), name="static")
 
 
 
 
73
 
74
 
75
  @app.route('/status')
 
61
 
62
  from fastapi.staticfiles import StaticFiles
63
 
64
+ app.mount("/static", StaticFiles(directory="static"), name="static")
65
 
66
+ # Serve your main HTML file
67
  @app.get("/")
68
  async def root():
69
+ return FileResponse("index.html")
 
70
 
71
+ # Optional: If you need to serve other static files individually
72
+ @app.get("/{filename}")
73
+ async def serve_file(filename: str):
74
+ if filename in ['style.css', 'script.js']:
75
+ return FileResponse(f"static/{filename}")
76
+ return FileResponse(f"static/{filename}")
77
 
78
 
79
  @app.route('/status')