Skip to content

Instantly share code, notes, and snippets.

@carlosm27
Last active November 23, 2022 17:32
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/cee266f2b744dc137d4b4fcfd78bb11b to your computer and use it in GitHub Desktop.
Save carlosm27/cee266f2b744dc137d4b4fcfd78bb11b to your computer and use it in GitHub Desktop.
get_fruit handler
@app.get("/fruit/:id")
def get_fruit(request):
id = request['params']['id']
fruit_id = int(id)
fruit = get_item(fruit_id, fake_fruit_database)
if fruit == {}:
return {"status_code":404,"body":"Fruit not Found", "type": "text"}
else:
return jsonify(fruit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment