Update app.py

This commit is contained in:
2026-09-08 17:23:22 +00:00
parent c0292a63f3
commit 317d6bfd9e
+12 -1
View File
@@ -11,4 +11,15 @@ def home():
def get_products():
with open("products.json", "r") as 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"}