wanderhome-quiz/server/app/views.py

25 lines
592 B
Python

from .tools.data import check_file, load
from .tools.quiz import compile_results, evaluate_answers, render_questions
from flask import Blueprint, jsonify, request
from flask.helpers import abort
views = Blueprint(
name='views',
import_name=__name__
)
@views.route('/questions/')
def _questions():
return render_questions()
@views.route('/submit/', methods=['POST'])
def _submit():
answers = request.json
scores = evaluate_answers(answers)
results = compile_results(results=scores)
return jsonify(results)
@views.route('/results/')
def _results():
pass