added product lookup endpoint

This commit is contained in:
root
2026-09-08 17:39:51 +00:00
parent 317d6bfd9e
commit af3007ea00
+7 -7
View File
@@ -14,12 +14,12 @@ def get_products():
return products return products
@app.get("/products/{productid}") @app.get("/products/{productid}")
def get_product(productid:str): def get_product(productid: str):
with open("products.json", "r") as file: with open("products.json", "r") as file:
products = json.load(file) products = json.load(file)
for product in products: for product in products:
if product["productid"] == productid: if product["productid"] == productid:
return product return product
return {"error": "Product not found"} return {"error": "Product not found"}