Commit ·
d6bdedb
1
Parent(s): c685bff
improving my root endpoint
Browse files- app/main.py +50 -19
app/main.py
CHANGED
|
@@ -64,29 +64,60 @@ class Patients(BaseModel):
|
|
| 64 |
# Root Endpoint
|
| 65 |
@app.get("/")
|
| 66 |
def root():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
return {
|
| 68 |
-
"message":
|
| 69 |
-
"description": "This API provides endpoints for predicting sepsis based on patient data.",
|
| 70 |
-
"endpoints": [
|
| 71 |
-
{
|
| 72 |
-
"url": "/",
|
| 73 |
-
"method": "GET",
|
| 74 |
-
"description": "Root endpoint providing information about the API."
|
| 75 |
-
},
|
| 76 |
-
{
|
| 77 |
-
"url": "/predict",
|
| 78 |
-
"method": "POST",
|
| 79 |
-
"description": "Endpoint to make a single patient sepsis prediction."
|
| 80 |
-
},
|
| 81 |
-
{
|
| 82 |
-
"url": "/predict_multiple",
|
| 83 |
-
"method": "POST",
|
| 84 |
-
"description": "Endpoint to make sepsis predictions for multiple patients."
|
| 85 |
-
}
|
| 86 |
-
]
|
| 87 |
}
|
| 88 |
|
| 89 |
|
|
|
|
| 90 |
# Prediction endpoint
|
| 91 |
@app.post("/predict")
|
| 92 |
def predict_sepsis(patient: Patient):
|
|
|
|
| 64 |
# Root Endpoint
|
| 65 |
@app.get("/")
|
| 66 |
def root():
|
| 67 |
+
message = """
|
| 68 |
+
Welcome to the Sepsis Prediction API!
|
| 69 |
+
|
| 70 |
+
This API provides endpoints for predicting sepsis based on patient data.
|
| 71 |
+
|
| 72 |
+
Endpoints:
|
| 73 |
+
|
| 74 |
+
[GET] /
|
| 75 |
+
Description: Root endpoint providing information about the API.
|
| 76 |
+
|
| 77 |
+
[POST] /predict
|
| 78 |
+
Description: Endpoint to make a single patient sepsis prediction.
|
| 79 |
+
Input: JSON payload containing patient data.
|
| 80 |
+
Example Payload:
|
| 81 |
+
{
|
| 82 |
+
"Blood_Work_R1": 123,
|
| 83 |
+
"Blood_Pressure": 80,
|
| 84 |
+
"Blood_Work_R3": 100,
|
| 85 |
+
"BMI": 25.5,
|
| 86 |
+
"Blood_Work_R4": 4.7,
|
| 87 |
+
"Patient_age": 50
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
[POST] /predict_multiple
|
| 91 |
+
Description: Endpoint to make sepsis predictions for multiple patients.
|
| 92 |
+
Input: JSON payload containing an array of patient objects.
|
| 93 |
+
Example Payload:
|
| 94 |
+
{
|
| 95 |
+
"all_patients": [
|
| 96 |
+
{
|
| 97 |
+
"Blood_Work_R1": 123,
|
| 98 |
+
"Blood_Pressure": 80,
|
| 99 |
+
"Blood_Work_R3": 100,
|
| 100 |
+
"BMI": 25.5,
|
| 101 |
+
"Blood_Work_R4": 4.7,
|
| 102 |
+
"Patient_age": 50
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"Blood_Work_R1": 140,
|
| 106 |
+
"Blood_Pressure": 90,
|
| 107 |
+
"Blood_Work_R3": 95,
|
| 108 |
+
"BMI": 27.2,
|
| 109 |
+
"Blood_Work_R4": 5.2,
|
| 110 |
+
"Patient_age": 45
|
| 111 |
+
}
|
| 112 |
+
]
|
| 113 |
+
}
|
| 114 |
+
"""
|
| 115 |
return {
|
| 116 |
+
"message": message.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
}
|
| 118 |
|
| 119 |
|
| 120 |
+
|
| 121 |
# Prediction endpoint
|
| 122 |
@app.post("/predict")
|
| 123 |
def predict_sepsis(patient: Patient):
|