Last active
November 20, 2021 13:04
-
-
Save aguilard07/8308ba5feea5a545fc8a36886a8dae56 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
# Create users | |
@app.route("/user", methods=["POST"]) | |
def create_user(): | |
data = request.get_json() | |
hashed_password = generate_password_hash(data["password"], method="sha256") | |
new_user = User( | |
username=data["username"], | |
password=hashed_password, | |
admin=False, | |
) | |
db.session.add(new_user) | |
db.session.commit() | |
return jsonify({"message": "New user created."}), 201 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment