diff --git a/app.js b/app.js
deleted file mode 100644
index e2c05ee..0000000
--- a/app.js
+++ /dev/null
@@ -1,34 +0,0 @@
-function updateMetrics() {
- fetch('/api/metrics')
- .then(response => response.json())
- .then(data => {
- document.getElementById('network-health').innerHTML = `
-
-
Network Health
-
CPU: ${data.network_health.cpu_percent}%
-
Memory: ${data.network_health.memory_percent}%
-
Connections: ${data.network_health.network_connections}
-
- `;
-
- document.getElementById('latency').innerHTML = `
-
-
Latency
-
${data.latency.toFixed(2)} ms
-
- `;
-
- document.getElementById('bandwidth').innerHTML = `
-
-
Bandwidth
-
Download: ${data.bandwidth.download.toFixed(2)} Mbps
-
Upload: ${data.bandwidth.upload.toFixed(2)} Mbps
-
- `;
- });
-}
-
-// Update metrics every 30 seconds
-setInterval(updateMetrics, 30000);
-// Initial update
-updateMetrics();
diff --git a/app.py b/app.py
new file mode 100644
index 0000000..9469088
--- /dev/null
+++ b/app.py
@@ -0,0 +1,39 @@
+from flask import Flask, render_template, jsonify
+import subprocess
+import platform
+import json
+import threading
+import time
+
+app = Flask(__name__)
+
+def ping(host):
+ param = '-n' if platform.system().lower() == 'windows' else '-c'
+ command = ['ping', param, '1', host]
+ return subprocess.call(command, stdout=subprocess.DEVNULL) == 0
+
+def load_config():
+ with open('config.json') as f:
+ return json.load(f)
+
+device_status = {}
+
+def update_status():
+ while True:
+ config = load_config()
+ for device in config['devices']:
+ device_status[device['name']] = ping(device['ip'])
+ time.sleep(config['check_interval'])
+
+@app.route('/')
+def home():
+ return render_template('index.html')
+
+@app.route('/api/status')
+def status():
+ return jsonify(device_status)
+
+if __name__ == '__main__':
+ status_thread = threading.Thread(target=update_status, daemon=True)
+ status_thread.start()
+ app.run(debug=True)
diff --git a/config.json b/config.json
new file mode 100644
index 0000000..7e722e2
--- /dev/null
+++ b/config.json
@@ -0,0 +1,25 @@
+{
+ "devices": [
+ {
+ "name": "UniFi Dream Machine Pro",
+ "ip": "192.168.1.1",
+ "type": "router"
+ },
+ {
+ "name": "UniFi Switch 24 PoE",
+ "ip": "192.168.1.2",
+ "type": "switch"
+ },
+ {
+ "name": "AP Living Room",
+ "ip": "192.168.1.10",
+ "type": "access_point"
+ },
+ {
+ "name": "AP Office",
+ "ip": "192.168.1.11",
+ "type": "access_point"
+ }
+ ],
+ "check_interval": 30
+}
diff --git a/index.html b/index.html
index 8f9e423..0e00ba2 100644
--- a/index.html
+++ b/index.html
@@ -8,7 +8,7 @@
diff --git a/static/app.js b/static/app.js
new file mode 100644
index 0000000..f22b965
--- /dev/null
+++ b/static/app.js
@@ -0,0 +1,18 @@
+function updateDeviceStatus() {
+ fetch('/api/status')
+ .then(response => response.json())
+ .then(data => {
+ Object.entries(data).forEach(([deviceName, isUp]) => {
+ const deviceElement = document.querySelector(`.device-status:has(span:contains("${deviceName}"))`);
+ if (deviceElement) {
+ const indicator = deviceElement.querySelector('.status-indicator');
+ indicator.className = `status-indicator status-${isUp ? 'up' : 'down'}`;
+ }
+ });
+ });
+}
+
+// Update every 30 seconds
+setInterval(updateDeviceStatus, 30000);
+// Initial update
+updateDeviceStatus();