Commit
·
b8ac588
1
Parent(s):
7bdaa4b
Update main.py
Browse files
main.py
CHANGED
@@ -29,30 +29,11 @@ async def read_root():
|
|
29 |
|
30 |
@app.get("/form/")
|
31 |
async def show_form():
|
32 |
-
request: Request,
|
33 |
-
prg: float = Query(..., description="Plasma glucose"),
|
34 |
-
pl: float = Query(..., description="Blood Work Result-1 (mu U/ml)"),
|
35 |
-
pr: float = Query(..., description="Blood Pressure (mm Hg)"),
|
36 |
-
sk: float = Query(..., description="Blood Work Result-2 (mm)"),
|
37 |
-
ts: float = Query(..., description="Blood Work Result-3 (mu U/ml)"),
|
38 |
-
m11: float = Query(..., description="Body mass index (weight in kg/(height in m)^2"),
|
39 |
-
bd2: float = Query(..., description="Blood Work Result-4 (mu U/ml)"),
|
40 |
-
age: int = Query(..., description="Patient's age (years)")
|
41 |
-
return templates.TemplateResponse("input_form.html", {"request": None})
|
42 |
|
43 |
@app.post("/predict/")
|
44 |
async def predict_diabetes(
|
45 |
request: Request,
|
46 |
input_data: InputFeatures # Use the Pydantic model for input validation
|
47 |
-
request: Request,
|
48 |
-
prg: float = Query(..., description="Plasma glucose"),
|
49 |
-
pl: float = Query(..., description="Blood Work Result-1 (mu U/ml)"),
|
50 |
-
pr: float = Query(..., description="Blood Pressure (mm Hg)"),
|
51 |
-
sk: float = Query(..., description="Blood Work Result-2 (mm)"),
|
52 |
-
ts: float = Query(..., description="Blood Work Result-3 (mu U/ml)"),
|
53 |
-
m11: float = Query(..., description="Body mass index (weight in kg/(height in m)^2"),
|
54 |
-
bd2: float = Query(..., description="Blood Work Result-4 (mu U/ml)"),
|
55 |
-
age: int = Query(..., description="Patient's age (years)")
|
56 |
):
|
57 |
try:
|
58 |
# Convert Pydantic model to a DataFrame for prediction
|
@@ -79,4 +60,5 @@ async def predict_diabetes(
|
|
79 |
}
|
80 |
)
|
81 |
except Exception as e:
|
82 |
-
raise HTTPException(status_code=500, detail="An error occurred while processing the request.")
|
|
|
|
29 |
|
30 |
@app.get("/form/")
|
31 |
async def show_form():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
@app.post("/predict/")
|
34 |
async def predict_diabetes(
|
35 |
request: Request,
|
36 |
input_data: InputFeatures # Use the Pydantic model for input validation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
):
|
38 |
try:
|
39 |
# Convert Pydantic model to a DataFrame for prediction
|
|
|
60 |
}
|
61 |
)
|
62 |
except Exception as e:
|
63 |
+
#raise HTTPException(status_code=500, detail="An error occurred while processing the request.")
|
64 |
+
raise HTTPException(status_code=500, detail=str(e))
|