Spaces:
Sleeping
Sleeping
dylanglenister
commited on
Commit
·
77b9e4d
1
Parent(s):
bc35722
Added a page for checking system health.
Browse filesLater this will likely be locked behind some kind of admin account
- api/routes/static.py +10 -0
- static/health.html +39 -0
api/routes/static.py
CHANGED
|
@@ -12,3 +12,13 @@ async def get_medical_chatbot():
|
|
| 12 |
return HTMLResponse(content=html_content)
|
| 13 |
except FileNotFoundError:
|
| 14 |
raise HTTPException(status_code=404, detail="Medical chatbot UI not found")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
return HTMLResponse(content=html_content)
|
| 13 |
except FileNotFoundError:
|
| 14 |
raise HTTPException(status_code=404, detail="Medical chatbot UI not found")
|
| 15 |
+
|
| 16 |
+
@router.get("/health-status", response_class=HTMLResponse)
|
| 17 |
+
async def get_health_status():
|
| 18 |
+
"""Serve the health status UI"""
|
| 19 |
+
try:
|
| 20 |
+
with open("static/health.html", "r", encoding="utf-8") as f:
|
| 21 |
+
html_content = f.read()
|
| 22 |
+
return HTMLResponse(content=html_content)
|
| 23 |
+
except FileNotFoundError:
|
| 24 |
+
raise HTTPException(status_code=404, detail="Health status UI not found")
|
static/health.html
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<title>System Health Status</title>
|
| 5 |
+
<style>
|
| 6 |
+
.status-ok { color: green; }
|
| 7 |
+
.status-error { color: red; }
|
| 8 |
+
body { font-family: Arial, sans-serif; padding: 20px; }
|
| 9 |
+
.component { margin: 10px 0; }
|
| 10 |
+
</style>
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
<h1>System Health Status</h1>
|
| 14 |
+
<div id="status"></div>
|
| 15 |
+
<script>
|
| 16 |
+
async function updateHealth() {
|
| 17 |
+
try {
|
| 18 |
+
const response = await fetch('/health');
|
| 19 |
+
const data = await response.json();
|
| 20 |
+
const statusHtml = `
|
| 21 |
+
<p>Status: <span class="status-${data.status === 'healthy' ? 'ok' : 'error'}">${data.status}</span></p>
|
| 22 |
+
<p>Timestamp: ${data.timestamp}</p>
|
| 23 |
+
<h3>Components:</h3>
|
| 24 |
+
${Object.entries(data.components).map(([key, value]) => `
|
| 25 |
+
<div class="component">
|
| 26 |
+
${key}: <span class="status-${value === 'operational' ? 'ok' : 'error'}">${value}</span>
|
| 27 |
+
</div>
|
| 28 |
+
`).join('')}
|
| 29 |
+
`;
|
| 30 |
+
document.getElementById('status').innerHTML = statusHtml;
|
| 31 |
+
} catch (error) {
|
| 32 |
+
document.getElementById('status').innerHTML = '<p class="status-error">Error fetching health status</p>';
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
updateHealth();
|
| 36 |
+
setInterval(updateHealth, 30000);
|
| 37 |
+
</script>
|
| 38 |
+
</body>
|
| 39 |
+
</html>
|