Created
March 16, 2021 11:42
-
-
Save oscar-defelice/90c49d121bb5ca1c57f2c74d959a50c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI, HTTPException | |
from ai.services import get_predictions | |
from core import config | |
from schemas.schemas import InputData, ResponseDataAPI | |
app = FastAPI(title=config.PROJECT_NAME, version=config.VERSION, openapi_url="/v1/openapi.json") | |
@app.get("/status") | |
def status(): | |
return "running" | |
@app.post("/v1/services/predict", tags=["services"], response_model=ResponseDataAPI) | |
def predict(data: InputData): | |
X = data.data | |
if len(X)==0: | |
raise HTTPException(status_code=400, detail="Empty data") | |
return { | |
"inputData": data, | |
"predictions": get_predictions(X), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment