Remove unnecessary files
هذا الالتزام موجود في:
@@ -35,6 +35,10 @@
|
||||
font-weight:bold;
|
||||
color:green;
|
||||
}
|
||||
|
||||
span.down{
|
||||
color:red;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
@@ -64,25 +68,39 @@
|
||||
|
||||
<script>
|
||||
|
||||
// IMPORTANT: change this after deploying to ghaymah.systems
|
||||
// e.g. "https://your-app-name.ghaymah.systems"
|
||||
const API_URL = "http://127.0.0.1:8000";
|
||||
|
||||
async function updateDashboard() {
|
||||
|
||||
try {
|
||||
|
||||
const response = await fetch("http://127.0.0.1:8000/stats");
|
||||
// Measure real round-trip latency from the browser's point of view
|
||||
const clientStart = performance.now();
|
||||
|
||||
const response = await fetch(`${API_URL}/stats`);
|
||||
const data = await response.json();
|
||||
|
||||
document.getElementById("status").textContent = data.status;
|
||||
const clientLatency = Math.round(performance.now() - clientStart);
|
||||
|
||||
const statusEl = document.getElementById("status");
|
||||
statusEl.textContent = data.status;
|
||||
statusEl.classList.toggle("down", data.status !== "UP");
|
||||
|
||||
document.getElementById("requests").textContent = data.requests;
|
||||
|
||||
document.getElementById("response").textContent = data.response_time;
|
||||
// Show the server-measured latency; fall back to client-measured
|
||||
// round-trip time if the server didn't report anything useful.
|
||||
document.getElementById("response").textContent =
|
||||
data.response_time > 0 ? data.response_time : clientLatency;
|
||||
|
||||
}
|
||||
|
||||
catch(error){
|
||||
|
||||
document.getElementById("status").textContent = "DOWN";
|
||||
const statusEl = document.getElementById("status");
|
||||
statusEl.textContent = "DOWN";
|
||||
statusEl.classList.add("down");
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +108,7 @@ async function updateDashboard() {
|
||||
|
||||
updateDashboard();
|
||||
|
||||
setInterval(updateDashboard,30000);
|
||||
setInterval(updateDashboard, 30000);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم