Spaces:
Sleeping
Sleeping
Update routers/electronics_router.py
Browse files- 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"
|
| 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 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 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}
|