pvanand commited on
Commit
8e2fea8
·
verified ·
1 Parent(s): 52b8c04

Update routers/electronics_router.py

Browse files
Files changed (1) hide show
  1. routers/electronics_router.py +25 -33
routers/electronics_router.py CHANGED
@@ -6,14 +6,6 @@ import random
6
 
7
  router = APIRouter(prefix="/api/electronics", tags=["electronics"])
8
 
9
- class ElectronicProduct(BaseModel):
10
- id: int
11
- name: str
12
- category: str
13
- price: float
14
- specs: dict
15
- stock: int
16
- rating: float
17
 
18
  @router.get("/products")
19
  async def get_products():
@@ -21,32 +13,32 @@ async def get_products():
21
  categories = ["Smartphones", "Laptops", "Tablets", "Smartwatches"]
22
  products = []
23
 
24
- for i in range(20):
25
- category = random.choice(categories)
26
 
27
- specs = {
28
- "Smartphones": {
29
- "screen": f"{random.choice([5.5, 6.1, 6.7])} inches",
30
- "storage": f"{random.choice([64, 128, 256, 512])}GB",
31
- "ram": f"{random.choice([4, 6, 8, 12])}GB",
32
- "camera": f"{random.choice([12, 48, 64, 108])}MP"
33
- },
34
- "Laptops": {
35
- "screen": f"{random.choice([13, 14, 15.6, 16])} inches",
36
- "storage": f"{random.choice([256, 512, 1024])}GB SSD",
37
- "ram": f"{random.choice([8, 16, 32])}GB",
38
- "processor": f"Core i{random.choice([5, 7, 9])}"
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}
 
6
 
7
  router = APIRouter(prefix="/api/electronics", tags=["electronics"])
8
 
 
 
 
 
 
 
 
 
9
 
10
  @router.get("/products")
11
  async def get_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}