Created
November 23, 2022 17:42
-
-
Save carlosm27/f6ec4d16d2886cee180ab2dbe5541114 to your computer and use it in GitHub Desktop.
delete_fruit handler
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.delete("/fruit/:id") | |
def delete_fruit(request): | |
id = request["params"]["id"] | |
fruit_id = int(id) | |
fruit_dict = get_item(fruit_id,fake_fruit_database) | |
if fruit_dict == {}: | |
return {"status_code":404,"body":"Fruit not Found", "type": "text"} | |
else: | |
fake_fruit_database.remove(fruit_dict) | |
return jsonify({"Message":"Fruit was deleted"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment