File size: 648 Bytes
5f10e37 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from app.utils.predict import predict_quality
import uvicorn
app = FastAPI(title="CNN SP500 Predictor")
class InputData(BaseModel):
data: list # lista de listas com as features
@app.post("/predict")
def predict(input_data: InputData):
try:
prediction = predict_quality(input_data.data)
return {"prediction": prediction}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
# Descomente se for rodar diretamente
# if __name__ == "__main__":
# uvicorn.run(app, host="0.0.0.0", port=8000)
|