-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (23 loc) · 726 Bytes
/
main.py
File metadata and controls
30 lines (23 loc) · 726 Bytes
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
from fastapi import Response, status
from fastapi import FastAPI, UploadFile
from fastapi.middleware.cors import CORSMiddleware
from controller import inference
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=['*'],
allow_credentials=False,
allow_methods=['GET', 'POST'],
allow_headers=["*"],
)
@app.post("/predict/", status_code=200)
async def predict(fileUpload: UploadFile, response: Response):
res, responseBody = inference(file=fileUpload)
if res:
return responseBody
else:
response.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
return {'message': 'ERROR'}
@app.get("/")
async def root():
return {"message": "Hello I'm Beefy AI"}