Update app.py
This commit is contained in:
@@ -12,3 +12,14 @@ def get_products():
|
|||||||
with open("products.json", "r") as file:
|
with open("products.json", "r") as file:
|
||||||
products = json.load(file)
|
products = json.load(file)
|
||||||
return products
|
return products
|
||||||
|
|
||||||
|
@app.get("/products/{productid}")
|
||||||
|
def get_product(productid:str):
|
||||||
|
with open("products.json", "r") as file:
|
||||||
|
products = json.load(file)
|
||||||
|
|
||||||
|
for product in products:
|
||||||
|
if product["productid"] == productid:
|
||||||
|
return product
|
||||||
|
|
||||||
|
return {"error": "Product not found"}
|
||||||
Reference in New Issue
Block a user