aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-01-15 10:49:47 +0100
committerlonkaars <l.leblansch@gmail.com>2021-01-15 10:49:47 +0100
commita6174bafcfac58d2f6bc3537870d3a3e3b76cc8f (patch)
tree80edfb621fd65f70be332302b15e50331a1f43e2
parentedcbbb61b8f6278404955d6758d4c1129f8dbc8a (diff)
heb gedeeltelijk user/info geïmplementeerd
-rwxr-xr-xapi/tests.sh13
-rw-r--r--api/user/info.py27
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],
+ }