Spaces:
Sleeping
Sleeping
madamanastasia commited on
Commit ·
e66b965
1
Parent(s): 54774bc
Fix app instance and add root landing page
Browse files
main.py
CHANGED
|
@@ -7,7 +7,12 @@ import joblib
|
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
|
| 10 |
-
app = FastAPI(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
@app.get("/", response_class=HTMLResponse)
|
| 13 |
def home():
|
|
@@ -37,13 +42,6 @@ FEATURE_ORDER = [
|
|
| 37 |
"winter_tires",
|
| 38 |
]
|
| 39 |
|
| 40 |
-
app = FastAPI(
|
| 41 |
-
title="Getaround API",
|
| 42 |
-
version="1.0.0",
|
| 43 |
-
docs_url=None, # we serve a custom /docs page to match the project requirement
|
| 44 |
-
redoc_url=None
|
| 45 |
-
)
|
| 46 |
-
|
| 47 |
model = joblib.load(MODEL_PATH)
|
| 48 |
|
| 49 |
class PredictIn(BaseModel):
|
|
@@ -79,13 +77,9 @@ def predict(payload: PredictIn):
|
|
| 79 |
return {"prediction": [float(p) for p in preds]}
|
| 80 |
|
| 81 |
|
| 82 |
-
from fastapi.responses import HTMLResponse
|
| 83 |
-
from pathlib import Path
|
| 84 |
-
|
| 85 |
BASE_DIR = Path(__file__).resolve().parent
|
| 86 |
|
| 87 |
@app.get("/docs", response_class=HTMLResponse)
|
| 88 |
def docs():
|
| 89 |
html = (BASE_DIR / "docs.html").read_text(encoding="utf-8")
|
| 90 |
-
return HTMLResponse(content=html)
|
| 91 |
-
|
|
|
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
|
| 10 |
+
app = FastAPI(
|
| 11 |
+
title="Getaround API",
|
| 12 |
+
version="1.0.0",
|
| 13 |
+
docs_url=None,
|
| 14 |
+
redoc_url=None
|
| 15 |
+
)
|
| 16 |
|
| 17 |
@app.get("/", response_class=HTMLResponse)
|
| 18 |
def home():
|
|
|
|
| 42 |
"winter_tires",
|
| 43 |
]
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
model = joblib.load(MODEL_PATH)
|
| 46 |
|
| 47 |
class PredictIn(BaseModel):
|
|
|
|
| 77 |
return {"prediction": [float(p) for p in preds]}
|
| 78 |
|
| 79 |
|
|
|
|
|
|
|
|
|
|
| 80 |
BASE_DIR = Path(__file__).resolve().parent
|
| 81 |
|
| 82 |
@app.get("/docs", response_class=HTMLResponse)
|
| 83 |
def docs():
|
| 84 |
html = (BASE_DIR / "docs.html").read_text(encoding="utf-8")
|
| 85 |
+
return HTMLResponse(content=html)
|
|
|