Update predict.py
Browse files- predict.py +7 -0
predict.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from typing import Literal
|
|
|
|
| 3 |
import uvicorn
|
| 4 |
import pickle
|
| 5 |
# for data validation, so the data input by the user is realistic
|
|
@@ -36,6 +37,12 @@ class PredictResponse(BaseModel):
|
|
| 36 |
|
| 37 |
app = FastAPI(title="Customer Conversion Predictor")
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
# Load the pre-trained model
|
| 40 |
with open("model.bin", "rb") as f_in:
|
| 41 |
pipeline = pickle.load(f_in)
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from typing import Literal
|
| 3 |
+
from fastapi.responses import RedirectResponse
|
| 4 |
import uvicorn
|
| 5 |
import pickle
|
| 6 |
# for data validation, so the data input by the user is realistic
|
|
|
|
| 37 |
|
| 38 |
app = FastAPI(title="Customer Conversion Predictor")
|
| 39 |
|
| 40 |
+
|
| 41 |
+
@app.get("/", include_in_schema=False)
|
| 42 |
+
def redirect_to_docs():
|
| 43 |
+
"""Redirects the root URL of the Space (/) to the FastAPI documentation (/docs)."""
|
| 44 |
+
return RedirectResponse(url="/docs")
|
| 45 |
+
|
| 46 |
# Load the pre-trained model
|
| 47 |
with open("model.bin", "rb") as f_in:
|
| 48 |
pipeline = pickle.load(f_in)
|