MCPcopy Create free account
hub / github.com/TechifyBots/Rename-Bot / root_route_handler

Function root_route_handler

plugins/web_support.py:51–77  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

49
50@TechifyBots.get("/", allow_head=True)
51async def root_route_handler(request):
52 # Get real-time status data - CORRECTED: use get_status() instead of get_bot_status() and get_live_status()
53 status_data = await get_status()
54 # Render template with actual data
55 with open('templates/welcome.html', 'r', encoding='utf-8') as f:
56 template_content = f.read()
57 # Replace placeholders with actual data - CORRECTED: use status_data dictionary
58 html_content = template_content
59 html_content = html_content.replace('{{bot_status}}', status_data['status'])
60 html_content = html_content.replace('{{bot_version}}', status_data['version'])
61 html_content = html_content.replace('{{total_users}}', str(status_data['total_users']))
62 html_content = html_content.replace('{{premium_users}}', str(status_data['total_premium_users']))
63 html_content = html_content.replace('{{bot_uptime}}', status_data['uptime'])
64 html_content = html_content.replace('{{data_sent}}', status_data['sent'])
65 html_content = html_content.replace('{{data_recv}}', status_data['recv'])
66 html_content = html_content.replace('{{system_uptime}}', status_data['uptime'])
67 html_content = html_content.replace('{{cpu_usage}}', str(status_data['cpu_usage']))
68 html_content = html_content.replace('{{ram_usage}}', str(status_data['ram_usage']))
69 html_content = html_content.replace('{{disk_usage}}', str(status_data['disk_usage']))
70 html_content = html_content.replace('{{total_disk}}', status_data['total_disk'])
71 html_content = html_content.replace('{{used_disk}}', status_data['used_disk'])
72 html_content = html_content.replace('{{free_disk}}', status_data['free_disk'])
73 html_content = html_content.replace('{{system_sent}}', status_data['sent'])
74 html_content = html_content.replace('{{system_recv}}', status_data['recv'])
75 # Add current timestamp for cache busting
76 html_content = html_content.replace('{{timestamp}}', str(int(time.time())))
77 return web.Response(text=html_content, content_type='text/html')
78
79async def web_server():
80 web_app = web.Application(client_max_size=30000000)

Callers

nothing calls this directly

Calls 1

get_statusFunction · 0.85

Tested by

no test coverage detected