pvanand commited on
Commit
925f82c
·
verified ·
1 Parent(s): 3e7c1cf

Update routers/electronics_router.py

Browse files
Files changed (1) hide show
  1. routers/electronics_router.py +11 -13
routers/electronics_router.py CHANGED
@@ -15,7 +15,7 @@ class ElectronicProduct(BaseModel):
15
  stock: int
16
  rating: float
17
 
18
- @router.get("/products", response_model=List[ElectronicProduct])
19
  async def get_products():
20
  # Sample data generator
21
  categories = ["Smartphones", "Laptops", "Tablets", "Smartwatches"]
@@ -39,16 +39,14 @@ async def get_products():
39
  }
40
  }.get(category, {"specs": "Basic specifications"})
41
 
42
- products.append(
43
- ElectronicProduct(
44
- id=i + 1,
45
- name=f"{category} Pro {random.randint(1, 100)}",
46
- category=category,
47
- price=round(random.uniform(299.99, 2999.99), 2),
48
- specs=specs,
49
- stock=random.randint(0, 100),
50
- rating=round(random.uniform(3.5, 5.0), 1)
51
- )
52
- )
53
 
54
- return products
 
15
  stock: int
16
  rating: float
17
 
18
+ @router.get("/products")
19
  async def get_products():
20
  # Sample data generator
21
  categories = ["Smartphones", "Laptops", "Tablets", "Smartwatches"]
 
39
  }
40
  }.get(category, {"specs": "Basic specifications"})
41
 
42
+ products.append({
43
+ "id": i + 1,
44
+ "name": f"{category} Pro {random.randint(1, 100)}",
45
+ "category": category,
46
+ "price": round(random.uniform(299.99, 2999.99), 2),
47
+ "specs": specs,
48
+ "stock": random.randint(0, 100),
49
+ "rating": round(random.uniform(3.5, 5.0), 1)
50
+ })
 
 
51
 
52
+ return {"products": products}