endorsement/user.py
2018-07-12 21:37:37 +02:00

15 lines
No EOL
354 B
Python

from app import app
from models import User
import json
@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()])