示例#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