Requirement:
Create a stores list with a dictionary of stores and items. items is again a list with dictionary of name and price.
Create a method which has a get endpoint to get the stores details in the list.
from flask import Flask,app
app = Flask(__name__)
stores = [
{
"name": "my store",
"items": [
{"name": "my item",
"price": 15.99
}
]
}
]
@app.get("/stores")
def get_stores():
return stores
Save the code in the VS code editor.
In your venv , run flask and hit the browser or post man with the URL
http://127.0.0.1:5000/stores
you get below output:

Top comments (0)