licorne2lc commited on
Commit
46e2bfc
·
1 Parent(s): 7ce110a

Fix PORT for Hugging Face deployment

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -5,6 +5,10 @@ from fastapi import FastAPI
5
  import numpy as np
6
  import joblib
7
  from typing import List
 
 
 
 
8
 
9
  # ==== FastAPI Description ====
10
 
@@ -63,8 +67,8 @@ async def predict(car_options: CarOptions):
63
  formatted = [f"Option {i+1}: {round(pred)} €" for i, pred in enumerate(predictions)]
64
  return {"predictions": formatted}
65
 
66
- # ==== Exécution locale ====
67
 
68
  if __name__ == "__main__":
69
- uvicorn.run(app, host="0.0.0.0", port=4000)
 
70
 
 
5
  import numpy as np
6
  import joblib
7
  from typing import List
8
+ import os
9
+
10
+
11
+
12
 
13
  # ==== FastAPI Description ====
14
 
 
67
  formatted = [f"Option {i+1}: {round(pred)} €" for i, pred in enumerate(predictions)]
68
  return {"predictions": formatted}
69
 
 
70
 
71
  if __name__ == "__main__":
72
+ port = int(os.environ.get("PORT", 7860)) # Hugging Face utilisera automatiquement ce port
73
+ uvicorn.run(app, host="0.0.0.0", port=port)
74