Skip to content

Instantly share code, notes, and snippets.

@carlosm27
Created November 23, 2022 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosm27/f6ec4d16d2886cee180ab2dbe5541114 to your computer and use it in GitHub Desktop.
Save carlosm27/f6ec4d16d2886cee180ab2dbe5541114 to your computer and use it in GitHub Desktop.
delete_fruit handler
@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