from flask_restful import Resource, reqparse from docker_verify import docker_verify from models import Answer, User, db from task_manager import TaskManager import os # Challenge data file URL CHALLENGES_PATH = 'data/challenges.json' # Static variables manager = TaskManager(CHALLENGES_PATH) best_answer = [{ 'cc':float('inf'), 'java':float('inf'), 'js':float('inf'), 'py':float('inf')} for _ in manager.get_tasks()] tokens = {} # REST API Endpoints class AnswerResource(Resource): def post(self, task_id): ''' Endpoint for submitting code ''' parser = reqparse.RequestParser() parser.add_argument('language', required=True) parser.add_argument('code', required=True) args = parser.parse_args() task = manager.get_task(task_id) if task_id is None or task is None: # no task exists with the stated id return redirect('/?message=%s' % 'task does not exist.') test_cases = task.get('test_cases', None)