aboutsummaryrefslogtreecommitdiff
path: root/api/user/info.py
blob: b63e2c9ea03b3d89fccf2a2daa45a367511bfc34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Blueprint, request
from main import cursor

info = Blueprint('info', __name__)

@info.route('/info')
def index():
    data = request.get_json()

    username = data.get("username") or ""
    id = data.get("id") or ""

    if not username and \
       not id:
           return "", 400

    if username:
        user = cursor.execute("select username, user_id, country, type, registered, avatar from users where username = ?", [username]).fetchone()
    else:
        user = cursor.execute("select username, user_id, country, type, registered, avatar from users where user_id = ?", [id]).fetchone()

    #TODO: rating uitrekenen zodra er game functionaliteit is
    return {
        "username": user[0],
        "id": user[1],
        "country": user[2],
        "type": user[3],
        "registered": user[4],
        "avatar": user[5],
    }