crafty-4/app/classes/web/status_handler.py

41 lines
1.4 KiB
Python
Raw Normal View History

2021-08-27 01:06:22 +00:00
import logging
from app.classes.shared.helpers import helper
from app.classes.web.base_handler import BaseHandler
logger = logging.getLogger(__name__)
class StatusHandler(BaseHandler):
def get(self):
page_data = {}
page_data['lang'] = helper.get_setting('language')
2021-09-08 22:01:10 +00:00
page_data['servers'] = self.controller.servers.get_all_servers_stats()
2021-08-28 22:48:30 +00:00
for srv in page_data['servers']:
server_data = srv.get('server_data', False)
server_id = server_data.get('server_id', False)
2022-03-03 21:01:12 +00:00
srv['raw_ping_result'] = self.controller.servers.get_server_stats_by_id(server_id)
2021-08-27 01:06:22 +00:00
template = 'public/status.html'
self.render(
template,
data=page_data,
translate=self.translator.translate,
)
def post(self):
page_data = {}
2021-09-08 22:01:10 +00:00
page_data['servers'] = self.controller.servers.get_all_servers_stats()
2021-08-28 22:48:30 +00:00
for srv in page_data['servers']:
server_data = srv.get('server_data', False)
server_id = server_data.get('server_id', False)
2022-03-03 21:01:12 +00:00
srv['raw_ping_result'] = self.controller.servers.get_server_stats_by_id(server_id)
if not srv['raw_ping_result'].has_key('icon'):
srv['raw_ping_result']['icon'] = False
2021-08-27 01:06:22 +00:00
template = 'public/status.html'
self.render(
template,
data=page_data,
translate=self.translator.translate,
)