Esempio n. 1
0
def send_game_answer():
    if request.method == 'OPTIONS':
        return make_response(jsonify({}))

    json_data = request.json
    id_user = session_to_id_user(request.headers)
    json_data['id_user'] = id_user
    return make_response(jsonify(Processor().send_game_answer(json_data)))
Esempio n. 2
0
def profile(id_user):
    if request.method == 'OPTIONS':
        return make_response(jsonify({}))
    answer = Processor().profile(id_user)
    if answer:
        answer = answer[0]
    else:
        answer = {}
    return make_response(jsonify(answer))
Esempio n. 3
0
def all_rating():
    if request.method == 'OPTIONS':
        return make_response(jsonify({}))
    id_user = session_to_id_user(request.headers) or None
    top = Processor().get_top_users(id_user)
    func = {
        'top': top
    }
    answer = jsonify(func)
    return make_response(answer)
Esempio n. 4
0
def get_game_info():
    if request.method == 'OPTIONS':
        return make_response(jsonify({}))
    if request.method == 'GET':
        id_user = session_to_id_user(request.headers)
        return make_response(jsonify(Processor().get_game_info(id_user)))
    if request.method == 'POST':
        data = request.json
        check_session(data, request.headers)
        return make_response(jsonify(Processor().start_new_game(data)))
Esempio n. 5
0
def profile_user():
    if request.method == 'OPTIONS':
        return make_response(jsonify({}))
    id_user = session_to_id_user(request.headers)
    answer = Processor().profile(id_user)
    if answer:
        answer = answer[0]
    else:
        answer = {}
    return make_response(jsonify(answer))
Esempio n. 6
0
def register():
    if request.method == 'OPTIONS':
        return make_response(jsonify({}))
    data = request.json
    res = Processor().create(data)
    return make_response(jsonify(res))
Esempio n. 7
0
def login():
    if request.method == 'OPTIONS':
        return make_response(jsonify({}))
    data = request.json
    res = Processor().login(data)
    return make_response(jsonify(res))
Esempio n. 8
0
def all_user():
    return make_response(jsonify(Processor().users()))