Spaces:
Runtime error
Runtime error
Create app/routes/health.py
Browse files- app/routes/health.py +34 -0
app/routes/health.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Health check routes
|
| 3 |
+
"""
|
| 4 |
+
import os
|
| 5 |
+
from flask import Blueprint, jsonify, current_app
|
| 6 |
+
|
| 7 |
+
health_bp = Blueprint('health', __name__)
|
| 8 |
+
|
| 9 |
+
@health_bp.route("/health", methods=["GET"])
|
| 10 |
+
def health_check():
|
| 11 |
+
"""
|
| 12 |
+
Health check endpoint
|
| 13 |
+
"""
|
| 14 |
+
return jsonify({
|
| 15 |
+
"status": "healthy",
|
| 16 |
+
"service": "flask-openai-chat",
|
| 17 |
+
"version": "1.0.0"
|
| 18 |
+
}), 200
|
| 19 |
+
|
| 20 |
+
@health_bp.route("/", methods=["GET"])
|
| 21 |
+
def root():
|
| 22 |
+
"""
|
| 23 |
+
Root endpoint with API information
|
| 24 |
+
"""
|
| 25 |
+
return jsonify({
|
| 26 |
+
"message": "Flask OpenAI Chat API",
|
| 27 |
+
"version": "1.0.0",
|
| 28 |
+
"endpoints": {
|
| 29 |
+
"chat": "/chat (POST)",
|
| 30 |
+
"models": "/chat/models (GET)",
|
| 31 |
+
"health": "/health (GET)"
|
| 32 |
+
},
|
| 33 |
+
"documentation": "Send POST request to /chat with JSON: {'message': 'your message'}"
|
| 34 |
+
}), 200
|