aboutsummaryrefslogtreecommitdiff
path: root/src/lb_app/api.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lb_app/api.py')
-rw-r--r--src/lb_app/api.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lb_app/api.py b/src/lb_app/api.py
index 9827828..9ac2bef 100644
--- a/src/lb_app/api.py
+++ b/src/lb_app/api.py
@@ -27,7 +27,11 @@ user_model = api.model('User', {
class Users(Resource):
def get(self):
""" Get user list """
- return loads(dumps(user.all()))
+ users = loads(dumps(user.all()))
+ if not users:
+ return loads('{"msg": "No users"}'), 404
+ print(users)
+ return loads(dumps(user.all())), 200
@api.route('/user/register')
@@ -38,9 +42,7 @@ class Register(Resource):
args = request.get_json(force=True)
status = user.register(args.get('username'))
- if status is None:
- return loads('{"msg": "done"}'), 201
- return loads('{"msg": "'+status+'"}'), 200
+ return loads('{"msg": "'+status['msg']+'"}'), status['code']
@api.route('/users/<username>')
@api.doc(params={'username': 'Jean'})
@@ -49,6 +51,4 @@ class Remove(Resource):
""" Remove a user """
status = user.remove(username)
- if status is None:
- return loads('{"msg": "done"}'), 201
- return loads('{"msg": "'+status+'"}'), 200
+ return loads('{"msg": "'+status['msg']+'"}'), status['code']