Added /users and /users/(username)
This commit is contained in:
parent
4f2dcd9d93
commit
ac31b088b0
1 changed files with 12 additions and 2 deletions
|
@ -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()])
|
Loading…
Reference in a new issue