diff options
-rwxr-xr-x | api/tests.sh | 13 | ||||
-rw-r--r-- | api/user/info.py | 27 |
2 files changed, 35 insertions, 5 deletions
diff --git a/api/tests.sh b/api/tests.sh index 6608611..002f85f 100755 --- a/api/tests.sh +++ b/api/tests.sh @@ -35,6 +35,15 @@ login_email () { localhost:5000/api/auth/login } +user_info () { + curl -X GET \ + -H "Content-Type: application/json" \ + -d '{ + "username": "loekaars" + }' \ + localhost:5000/api/user/info +} + # login_token () { # curl -X POST \ # -H "Content-Type: application/json" \ @@ -45,7 +54,5 @@ login_email () { # localhost:5000/api/auth/token # } -signup -login_email -login_username +user_info diff --git a/api/user/info.py b/api/user/info.py index 9c08e67..b63e2c9 100644 --- a/api/user/info.py +++ b/api/user/info.py @@ -1,7 +1,30 @@ -from flask import Blueprint +from flask import Blueprint, request +from main import cursor info = Blueprint('info', __name__) @info.route('/info') def index(): - return "user info :tada:" + 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], + } |