Added /users and /users/(username)

This commit is contained in:
Robbe Van Herck 2018-07-12 20:58:49 +02:00
parent 4f2dcd9d93
commit ac31b088b0
No known key found for this signature in database
GPG key ID: 4D1C8E8FBD1C7188

View file

@ -1,4 +1,14 @@
from app import app, db from app import app, db
from models import User from models import User, Achievement
import json
print(User.query.all()) @app.route("/users/<username>")
def get_user(username):
user = User.query.filter_by(username=username).first()
if not user:
return "{}"
return json.dumps(user.to_obj())
@app.route("/users/")
def all_users():
return json.dumps([user.to_obj() for user in User.query.all()])