diff --git a/.replit b/.replit index af7007c..1b4063e 100644 --- a/.replit +++ b/.replit @@ -14,6 +14,10 @@ run = ["npm", "run", "start"] localPort = 5000 externalPort = 80 +[[ports]] +localPort = 41327 +externalPort = 3000 + [env] PORT = "5000" diff --git a/python_ml/main.py b/python_ml/main.py index cbdbfb7..d576067 100644 --- a/python_ml/main.py +++ b/python_ml/main.py @@ -388,26 +388,31 @@ async def get_stats(): # Log stats cursor.execute("SELECT COUNT(*) as total FROM network_logs") - total_logs = cursor.fetchone()['total'] + result = cursor.fetchone() + total_logs = result['total'] if result else 0 cursor.execute(""" SELECT COUNT(*) as recent FROM network_logs WHERE timestamp >= NOW() - INTERVAL '1 hour' """) - recent_logs = cursor.fetchone()['recent'] + result = cursor.fetchone() + recent_logs = result['recent'] if result else 0 # Detection stats cursor.execute("SELECT COUNT(*) as total FROM detections") - total_detections = cursor.fetchone()['total'] + result = cursor.fetchone() + total_detections = result['total'] if result else 0 cursor.execute(""" SELECT COUNT(*) as blocked FROM detections WHERE blocked = true """) - blocked_ips = cursor.fetchone()['blocked'] + result = cursor.fetchone() + blocked_ips = result['blocked'] if result else 0 # Router stats cursor.execute("SELECT COUNT(*) as total FROM routers WHERE enabled = true") - active_routers = cursor.fetchone()['total'] + result = cursor.fetchone() + active_routers = result['total'] if result else 0 # Latest training cursor.execute("""