diff --git a/app.py b/app.py index b951051..2d791da 100644 --- a/app.py +++ b/app.py @@ -11,4 +11,15 @@ def home(): def get_products(): with open("products.json", "r") as file: products = json.load(file) - return products \ No newline at end of file + 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"} \ No newline at end of file