2018-04-18 16:46:53 -04:00
|
|
|
"""
|
|
|
|
Routes and views for the flask application.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
from flask import render_template
|
2018-09-29 15:52:22 -04:00
|
|
|
from master import app, ctx
|
2018-04-21 18:18:20 -04:00
|
|
|
from master.resources.history_graph import HistoryGraph
|
2018-09-29 15:52:22 -04:00
|
|
|
from collections import defaultdict
|
2018-04-18 16:46:53 -04:00
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def home():
|
2018-05-21 17:09:27 -04:00
|
|
|
_history_graph = HistoryGraph().get(2880)
|
2018-04-18 16:46:53 -04:00
|
|
|
return render_template(
|
|
|
|
'index.html',
|
2018-04-21 18:18:20 -04:00
|
|
|
title='API Overview',
|
|
|
|
history_graph = _history_graph[0]['message'],
|
2018-04-23 17:03:50 -04:00
|
|
|
data_points = _history_graph[0]['data_points'],
|
|
|
|
instance_count = _history_graph[0]['instance_count'],
|
|
|
|
client_count = _history_graph[0]['client_count'],
|
2018-05-21 17:09:27 -04:00
|
|
|
server_count = _history_graph[0]['server_count']
|
2018-04-21 18:18:20 -04:00
|
|
|
)
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
|
|
@app.route('/servers')
|
|
|
|
def servers():
|
|
|
|
servers = defaultdict(list)
|
|
|
|
if len(ctx.instance_list.values()) > 0:
|
|
|
|
ungrouped_servers = [server for instance in ctx.instance_list.values() for server in instance.servers]
|
|
|
|
for server in ungrouped_servers:
|
|
|
|
servers[server.game].append(server)
|
|
|
|
return render_template(
|
|
|
|
'serverlist.html',
|
|
|
|
title = 'Server List',
|
|
|
|
games = servers
|
|
|
|
)
|