-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
34 lines (26 loc) · 765 Bytes
/
main.py
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
from fastapi import FastAPI, status, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from utils import get_code, Description
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
def root():
return "Welcome!"
@app.post("/icd10")
def get_code(payload: Description):
if len(payload.description) > 0:
text = payload.description
codes = get_code(text)
return {'ICD-10_Code': codes}
else:
raise HTTPException(
status_code=status.HTTP_406_NOT_ACCEPTABLE, detail="Empty descriptions not acceptable...")
if __name__ == "__main__":
import uvicorn
uvicorn.run(app)