implemented refresh with custom namedtuple json serialization workaround, changed switch to jsonify

This commit is contained in:
Xevion
2020-06-19 18:08:35 -05:00
parent d34aa7f620
commit 206c1acee4

View File

@@ -5,7 +5,7 @@ Handles backend routes assisting
"""
import json
from flask import request
from flask import request, jsonify, make_response
from trivia import app
from trivia.utils import lastModified
@@ -23,7 +23,7 @@ def changed():
"""
from trivia.utils import lastChange
time = int(request.args.get('last') or lastModified())
return json.dumps(lastChange < time)
return jsonify(lastChange < time)
@app.route("/api/refresh")
@@ -32,3 +32,8 @@ def refresh():
"""
Used for refreshing client-side table data. Returns a JSON response with all data necessary to build the table.
"""
from trivia.utils import teams
r = make_response(json.dumps([team._asdict() for team in teams]))
print(r)
r.mimetype = 'application/json'
return r