Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,6 +85,16 @@ threading.Thread(target=load_models_with_retries, daemon=True).start()
|
|
| 85 |
def home():
|
| 86 |
return render_template('index.html')
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
@app.route('/api/chat', methods=['POST'])
|
| 89 |
def chat():
|
| 90 |
if not models_loaded:
|
|
@@ -112,4 +122,5 @@ def chat():
|
|
| 112 |
})
|
| 113 |
|
| 114 |
if __name__ == '__main__':
|
|
|
|
| 115 |
app.run(host='0.0.0.0', port=8000)
|
|
|
|
| 85 |
def home():
|
| 86 |
return render_template('index.html')
|
| 87 |
|
| 88 |
+
@app.route('/health')
|
| 89 |
+
def health():
|
| 90 |
+
"""Check if the application is ready to process requests."""
|
| 91 |
+
status = "ready" if models_loaded else "initializing"
|
| 92 |
+
return jsonify({
|
| 93 |
+
"status": status,
|
| 94 |
+
"error": loading_error if loading_error else None,
|
| 95 |
+
"uptime": time.time() - app.start_time
|
| 96 |
+
})
|
| 97 |
+
|
| 98 |
@app.route('/api/chat', methods=['POST'])
|
| 99 |
def chat():
|
| 100 |
if not models_loaded:
|
|
|
|
| 122 |
})
|
| 123 |
|
| 124 |
if __name__ == '__main__':
|
| 125 |
+
app.start_time = time.time()
|
| 126 |
app.run(host='0.0.0.0', port=8000)
|