tfrere commited on
Commit
b0a6020
·
1 Parent(s): eadc77b
Files changed (1) hide show
  1. server/server.py +22 -22
server/server.py CHANGED
@@ -80,28 +80,28 @@ if IS_DOCKER:
80
  # En mode Docker (HF Space), on monte les fichiers statiques avec des types MIME spécifiques
81
  app.mount("/assets", StaticFiles(directory=os.path.join(STATIC_FILES_DIR, "assets"), html=False), name="assets")
82
 
83
- @app.get("/{full_path:path}")
84
- async def serve_spa(full_path: str):
85
- # Si le chemin pointe vers un fichier JavaScript
86
- if full_path.endswith('.js'):
87
- return FileResponse(
88
- os.path.join(STATIC_FILES_DIR, full_path),
89
- media_type='application/javascript'
90
- )
91
- # Si le chemin pointe vers un fichier CSS
92
- elif full_path.endswith('.css'):
93
- return FileResponse(
94
- os.path.join(STATIC_FILES_DIR, full_path),
95
- media_type='text/css'
96
- )
97
- # Pour tous les autres chemins, servir index.html
98
- return FileResponse(
99
- os.path.join(STATIC_FILES_DIR, "index.html"),
100
- media_type='text/html'
101
- )
102
- else:
103
- # En local, on monte simplement à la racine
104
- app.mount("/", StaticFiles(directory=STATIC_FILES_DIR, html=True), name="static")
105
 
106
  if __name__ == "__main__":
107
  import uvicorn
 
80
  # En mode Docker (HF Space), on monte les fichiers statiques avec des types MIME spécifiques
81
  app.mount("/assets", StaticFiles(directory=os.path.join(STATIC_FILES_DIR, "assets"), html=False), name="assets")
82
 
83
+ # @app.get("/{full_path:path}")
84
+ # async def serve_spa(full_path: str):
85
+ # # Si le chemin pointe vers un fichier JavaScript
86
+ # if full_path.endswith('.js'):
87
+ # return FileResponse(
88
+ # os.path.join(STATIC_FILES_DIR, full_path),
89
+ # media_type='application/javascript'
90
+ # )
91
+ # # Si le chemin pointe vers un fichier CSS
92
+ # elif full_path.endswith('.css'):
93
+ # return FileResponse(
94
+ # os.path.join(STATIC_FILES_DIR, full_path),
95
+ # media_type='text/css'
96
+ # )
97
+ # # Pour tous les autres chemins, servir index.html
98
+ # return FileResponse(
99
+ # os.path.join(STATIC_FILES_DIR, "index.html"),
100
+ # media_type='text/html'
101
+ # )
102
+ # else:
103
+ # # En local, on monte simplement à la racine
104
+ # app.mount("/", StaticFiles(directory=STATIC_FILES_DIR, html=True), name="static")
105
 
106
  if __name__ == "__main__":
107
  import uvicorn