Spaces:
Sleeping
Sleeping
Update app.py
#1
by
JairoDanielMT
- opened
app.py
CHANGED
@@ -3,6 +3,7 @@ from pydantic import BaseModel
|
|
3 |
import pickle
|
4 |
import numpy as np
|
5 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
6 |
|
7 |
# Cargar el modelo desde el archivo .pkl
|
8 |
with open("miarbolcancer.pkl", "rb") as f:
|
@@ -40,6 +41,12 @@ app.add_middleware(
|
|
40 |
allow_methods=["*"],
|
41 |
allow_headers=["*"],
|
42 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
# Definir el endpoint de predicción
|
44 |
@app.post("/predict/")
|
45 |
def predict(input_data: PredictionInput):
|
|
|
3 |
import pickle
|
4 |
import numpy as np
|
5 |
from fastapi.middleware.cors import CORSMiddleware
|
6 |
+
from fastapi.responses import RedirectResponse
|
7 |
|
8 |
# Cargar el modelo desde el archivo .pkl
|
9 |
with open("miarbolcancer.pkl", "rb") as f:
|
|
|
41 |
allow_methods=["*"],
|
42 |
allow_headers=["*"],
|
43 |
)
|
44 |
+
|
45 |
+
# Redirigir de "/" a "/docs"
|
46 |
+
@app.get("/")
|
47 |
+
def redirect_to_docs():
|
48 |
+
return RedirectResponse(url="/docs")
|
49 |
+
|
50 |
# Definir el endpoint de predicción
|
51 |
@app.post("/predict/")
|
52 |
def predict(input_data: PredictionInput):
|