Spaces:
Running
Running
Update routers/electronics_router.py
Browse files- routers/electronics_router.py +25 -25
routers/electronics_router.py
CHANGED
@@ -13,32 +13,32 @@ async def get_products():
|
|
13 |
categories = ["Smartphones", "Laptops", "Tablets", "Smartwatches"]
|
14 |
products = []
|
15 |
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
return {"products": products}
|
|
|
13 |
categories = ["Smartphones", "Laptops", "Tablets", "Smartwatches"]
|
14 |
products = []
|
15 |
|
16 |
+
for i in range(20):
|
17 |
+
category = random.choice(categories)
|
18 |
|
19 |
+
specs = {
|
20 |
+
"Smartphones": {
|
21 |
+
"screen": f"{random.choice([5.5, 6.1, 6.7])} inches",
|
22 |
+
"storage": f"{random.choice([64, 128, 256, 512])}GB",
|
23 |
+
"ram": f"{random.choice([4, 6, 8, 12])}GB",
|
24 |
+
"camera": f"{random.choice([12, 48, 64, 108])}MP"
|
25 |
+
},
|
26 |
+
"Laptops": {
|
27 |
+
"screen": f"{random.choice([13, 14, 15.6, 16])} inches",
|
28 |
+
"storage": f"{random.choice([256, 512, 1024])}GB SSD",
|
29 |
+
"ram": f"{random.choice([8, 16, 32])}GB",
|
30 |
+
"processor": f"Core i{random.choice([5, 7, 9])}"
|
31 |
+
}
|
32 |
+
}.get(category, {"specs": "Basic specifications"})
|
33 |
|
34 |
+
products.append({
|
35 |
+
"id": i + 1,
|
36 |
+
"name": f"{category} Pro {random.randint(1, 100)}",
|
37 |
+
"category": category,
|
38 |
+
"price": round(random.uniform(299.99, 2999.99), 2),
|
39 |
+
"specs": specs,
|
40 |
+
"stock": random.randint(0, 100),
|
41 |
+
"rating": round(random.uniform(3.5, 5.0), 1)
|
42 |
+
})
|
43 |
|
44 |
return {"products": products}
|