Download api.py from Shymaa98/VOIP: direct link, hf CLI and curl.
- Browser
- Download file 796 Bytes
-
https://huggingface.co/spaces/Shymaa98/VOIP/resolve/main/api.py
- Command line
-
hf download hf://spaces/Shymaa98/VOIP/api.py
-
curl -L -o api.py https://huggingface.co/spaces/Shymaa98/VOIP/resolve/main/api.py
796 Bytes
| 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 | |
| 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", | |
| } | |
| async def get_predict(): | |
| return get_latest_prediction() | |
| async def get_all(): | |
| return get_all_predictions() | |
| async def done(): | |
| return "It is Work" |