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('/fetch//') def _fetch(data_type): if not check_file(f'{data_type}.json'): return abort(404) if data_type == 'questions': return render_questions() return load(f'{data_type}.json') @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