Created
November 21, 2021 09:35
-
-
Save aguilard07/7e3fa8fcf973b8f7acd57c7a375e1eaa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get user by id | |
@app.route("/user/<int:id>", methods=["GET"]) | |
def get_user_by_id(id): | |
user = User.query.filter_by(id=id).first() | |
if not user: | |
return jsonify({"message": "Not user found."}), 404 | |
else: | |
user_data = {} | |
user_data["id"] = user.id | |
user_data["username"] = user.username | |
user_data["admin"] = user.admin | |
return jsonify({"user": user_data}), 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment