Spaces:
Sleeping
Sleeping
QnxprU69yCNg8XJ
commited on
Commit
·
00aa7e3
1
Parent(s):
1afdf52
Add home route with API documentation
Browse files
app.py
CHANGED
|
@@ -23,6 +23,31 @@ app = Flask(__name__)
|
|
| 23 |
# Load classifier globally
|
| 24 |
classifier_model = load_classifier()
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
@app.route('/predict_pneumonia', methods=['POST'])
|
| 27 |
def predict_pneumonia_endpoint():
|
| 28 |
if 'audio_file' not in request.files:
|
|
|
|
| 23 |
# Load classifier globally
|
| 24 |
classifier_model = load_classifier()
|
| 25 |
|
| 26 |
+
@app.route('/')
|
| 27 |
+
def home():
|
| 28 |
+
"""API documentation homepage"""
|
| 29 |
+
return jsonify({
|
| 30 |
+
"name": "Pneumonia Risk Assessment API",
|
| 31 |
+
"version": "1.0.0",
|
| 32 |
+
"description": "AI-powered API for assessing pneumonia risk from respiratory audio recordings",
|
| 33 |
+
"endpoints": {
|
| 34 |
+
"POST /predict_pneumonia": {
|
| 35 |
+
"description": "Analyze audio file for pneumonia risk",
|
| 36 |
+
"parameters": {
|
| 37 |
+
"audio_file": "Audio file (multipart/form-data)"
|
| 38 |
+
},
|
| 39 |
+
"response": {
|
| 40 |
+
"filename": "string",
|
| 41 |
+
"pneumonia_risk_score": "float (0.0-1.0)",
|
| 42 |
+
"risk_level": "string (Low/Moderate/High)",
|
| 43 |
+
"note": "string"
|
| 44 |
+
},
|
| 45 |
+
"example_curl": "curl -X POST -F 'audio_file=@recording.wav' https://your-space.hf.space/predict_pneumonia"
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"note": "This is an AI assessment tool, not a medical diagnostic device. Always consult healthcare professionals."
|
| 49 |
+
}), 200
|
| 50 |
+
|
| 51 |
@app.route('/predict_pneumonia', methods=['POST'])
|
| 52 |
def predict_pneumonia_endpoint():
|
| 53 |
if 'audio_file' not in request.files:
|