Scoreboard 181 — Dev Top
server listen 80; server_name scoreboard.internal; location / proxy_pass http://127.0.0.1:181; auth_basic "Dev Top Scoreboard"; auth_basic_user_file /etc/nginx/.htpasswd;
Run this script: sudo python3 scoreboard_181.py . Your scoreboard 181 dev top endpoint is now live at http://your-server-ip:181/dev/top . A raw JSON output is not a real scoreboard. You need a front-end that polls the endpoint and renders a leaderboard. Create an index.html file and serve it alongside your Python script. scoreboard 181 dev top
<!DOCTYPE html> <html> <head> <title>Scoreboard 181 - Dev Top</title> <style> body font-family: monospace; background: #0D1117; color: #C9D1D9; .scoreboard border-collapse: collapse; width: 100%; .scoreboard th, .scoreboard td border: 1px solid #30363D; padding: 12px; text-align: left; .scoreboard th background: #161B22; color: #58A6FF; .rank-1 background: #2D1B00; /* Gold hint */ .rank-2 background: #1C1C1C; /* Silver hint */ .rank-3 background: #2A1A1A; /* Bronze hint */ </style> </head> <body> <h1>📊 Dev Top Scoreboard (Port 181)</h1> <table class="scoreboard" id="scoreboardTable"> <thead> <tr><th>Rank</th><th>Process Name</th><th>PID</th><th>CPU %</th><th>Memory %</th></tr> </thead> <tbody id="scoreboardBody"></tbody> </table> <p>Last updated: <span id="timestamp">—</span></p> <script> async function fetchScoreboard() try const response = await fetch('/dev/top'); const data = await response.json(); const tbody = document.getElementById('scoreboardBody'); tbody.innerHTML = ''; data.top_dev_processes.forEach((proc, idx) => 'unknown'; row.insertCell(2).innerText = proc.pid; row.insertCell(3).innerText = proc.cpu_percent.toFixed(2); row.insertCell(4).innerText = proc.memory_percent.toFixed(2); ); document.getElementById('timestamp').innerText = new Date(data.timestamp * 1000).toLocaleTimeString(); catch (err) console.error('Scoreboard error:', err); setInterval(fetchScoreboard, 2000); fetchScoreboard(); </script> </body> </html> server listen 80; server_name scoreboard
# Gather top 5 processes by CPU usage processes = [] for proc in psutil.process_iter(['pid', 'name', 'cpu_percent', 'memory_percent']): try: processes.append(proc.info) except (psutil.NoSuchProcess, psutil.AccessDenied): pass # Sort by CPU usage (descending) top_processes = sorted(processes, key=lambda x: x['cpu_percent'], reverse=True)[:5] # Build scoreboard structure scoreboard = "timestamp": time.time(), "top_dev_processes": top_processes, "system_cpu": psutil.cpu_percent(interval=1), "system_memory": psutil.virtual_memory()._asdict() self.wfile.write(json.dumps(scoreboard).encode()) else: self.send_response(404) with socketserver.TCPServer(("", PORT), ScoreboardHandler) as httpd: print(f"Serving scoreboard on port PORT") httpd.serve_forever() You need a front-end that polls the endpoint