File size: 796 Bytes
da8dab8 e9c79f8 da8dab8 1b92a0d da8dab8 39afe31 da8dab8 39afe31 06ee2ee e9c79f8 f7eea1b 39afe31 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | from fastapi import FastAPI
from pydantic import BaseModel
from model.inference import inference
from db_utils import init_db, insert_prediction,get_latest_prediction,get_all_predictions
app = FastAPI()
init_db()
class InputData(BaseModel):
input: list
@app.post("/predict")
async def predict(data: InputData):
input_data = data.input
if not input_data:
return {"error": "No input data provided"}
result = inference(input_data)
insert_prediction(input_data, result)
return {
"message": "Prediction successful",
}
@app.get("/get_predict")
async def get_predict():
return get_latest_prediction()
@app.get("/get_all_predictions")
async def get_all():
return get_all_predictions()
@app.get("/")
async def done():
return "It is Work" |