Files @ 3e571d06ecc9
Branch filter:

Location: C3L-NOC/spaceapi/spaceapi/views.py

Dennis Fink
Use singleton dictonary and reimplement reload view
from flask import Blueprint, jsonify, render_template, abort

from .utils import request_wants_json, ActiveStatus
from .auth import httpauth

root_views = Blueprint('root', __name__)


@root_views.route('/')
def index():
    if request_wants_json():
        return jsonify(ActiveStatus())
    return render_template('index.html', status=ActiveStatus())


@root_views.route('/status.json')
def status_json():
    return jsonify(ActiveStatus())


@root_views.route('/reload')
@httpauth.login_required
def reload():
    active = ActiveStatus()
    active.reload()
    return jsonify(active)