Files @ 942e4eb9227f
Branch filter:

Location: FVDE/ennstatus/ennstatus/statistics/views.py

Dennis Fink
Fix api update from csrf protection

For now we simply exempt the protection
from collections import defaultdict

from flask import Blueprint, render_template, current_app, jsonify

from ennstatus.status.functions import split_all_servers_to_types

statistics_page = Blueprint('statistics', __name__)


@statistics_page.route('/worldmap')
def worldmap():
    return render_template('statistics/worldmap.html')


@statistics_page.route('/data/worldmap')
def data_worldmap():
    servers = split_all_servers_to_types()
    countries = defaultdict(int)

    for key, value in servers.items():
        for server in value:
            countries[server['country']] += 1

    maximum = max(countries.values())

    countries['max'] = maximum

    return jsonify(countries)