2018-07-12 19:45:52 +02:00
|
|
|
from app import app, db
|
2018-07-12 20:58:49 +02:00
|
|
|
from models import User, Achievement
|
|
|
|
import json
|
2018-07-12 19:45:52 +02:00
|
|
|
|
2018-07-12 20:58:49 +02:00
|
|
|
@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()])
|