예제 #1
0
파일: views.py 프로젝트: ZwodahS/mazehack
def view_execute_instructions(id, instruction):
    maze = db_get_maze(id)
    if maze is None:
        return jsonify({"error" : "Maze not found"}), 404
    elif instruction is None:
        return jsonify({"error" : "Empty instruction"}), 400
    
    success, instructions = runtime.compile(instruction)
    if not success:
        return jsonify(instructions), 200

    result = runtime.run_instructions(maze, instructions)
    print(result)
    return jsonify(result), 200
예제 #2
0
파일: views.py 프로젝트: ZwodahS/mazehack
def view_get_maze(id):
    maze = db_get_maze(id)
    if maze is None:
        return jsonify({}), 404
    return jsonify(maze), 200