Last active
November 23, 2022 17:32
-
-
Save carlosm27/cee266f2b744dc137d4b4fcfd78bb11b to your computer and use it in GitHub Desktop.
get_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.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