Last active
June 29, 2024 18:58
-
-
Save 5t33/58844169e2e0587bcbb5b1c6ff1a0fde to your computer and use it in GitHub Desktop.
validate_book_post
This file contains 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
@app.route('/book', methods=['POST']) | |
def create_book(): | |
data = request.get_json() | |
if not ("title" in data and "author" in data and "genre" in data): | |
return {"message": "\"title\", \"author\", and \"genre\" are required fields"}, 400 | |
library[data['title']] = data | |
return library[data['title']], 201 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment