Wanswan commited on
Commit
b24ba31
·
verified ·
1 Parent(s): 938550b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -6
app.py CHANGED
@@ -8,7 +8,34 @@ import pandas as pd
8
  # ====== 菜单数据结构(英文 + 编号) ======
9
  MENU_DATA = {
10
  "Appetizers": [
11
- {"id": "A1", "name": "Spring Rolls", "desc": "Crispy rolls with vegetables", "price": 4.5},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  {"id": "A2", "name": "Dumplings", "desc": "Steamed pork dumplings", "price": 5.0},
13
  {"id": "A3", "name": "Salad", "desc": "Fresh vegetable salad", "price": 3.5},
14
  {"id": "A4", "name": "Tofu Skewers", "desc": "Grilled tofu with sauce", "price": 4.0},
@@ -37,7 +64,6 @@ MENU_DATA = {
37
  ],
38
  }
39
 
40
-
41
  # ========== 功能函数 ==========
42
  def record_time(start_time):
43
  duration = round(time.time() - start_time, 2)
@@ -68,14 +94,19 @@ with gr.Blocks() as demo:
68
  with gr.Tab(label=category):
69
  for item in items:
70
  with gr.Row():
71
- gr.Image(value="user_avatar.jpg", width=100, height=100, show_label=False, interactive=False)
72
- gr.Markdown(f"**{item['id']} - {item['name']}**\n\n{item['desc']}\n\n💰 €{item['price']:.2f}")
 
 
 
 
73
 
74
- submit_btn = gr.Button("✅ I have made my selection")
 
75
  output_box = gr.Textbox(label="", lines=3, interactive=False)
76
  submit_btn.click(fn=record_time, inputs=[gr.State(value=start_time)], outputs=output_box)
77
 
78
- with gr.Accordion("📊 Admin Tools (optional)", open=False):
79
  gr.Markdown("### View or Clear Recorded CSV Data")
80
  show_btn = gr.Button("📥 Show CSV Data")
81
  show_output = gr.Textbox(label="decision_times.csv content", lines=10)
 
8
  # ====== 菜单数据结构(英文 + 编号) ======
9
  MENU_DATA = {
10
  "Appetizers": [
11
+ {"id": "A1", "name": "Spring Rolls", "desc": "Crispy rice paper rolls filled with mixed vegetables and glass noodles. Light and crunchy.", "price": 4.5},
12
+ {"id": "A2", "name": "Dumplings", "desc": "Steamed dumplings filled with seasoned pork and chives. Juicy and savory.", "price": 5.0},
13
+ {"id": "A3", "name": "Salad", "desc": "Fresh greens with cucumber, tomato, and sesame dressing. Light and refreshing.", "price": 3.5},
14
+ {"id": "A4", "name": "Tofu Skewers", "desc": "Grilled tofu skewers with sweet chili glaze. Crispy outside, tender inside.", "price": 4.0},
15
+ {"id": "A5", "name": "Edamame", "desc": "Boiled young soybeans with sea salt. Simple, healthy, and satisfying.", "price": 3.0},
16
+ ],
17
+ "Main Dishes": [
18
+ {"id": "B1", "name": "Beef Pho", "desc": "Vietnamese noodle soup with thin-sliced beef, herbs, and rich bone broth.", "price": 9.5},
19
+ {"id": "B2", "name": "Chicken Curry", "desc": "Spicy yellow curry with tender chicken, coconut milk, and vegetables. Served with rice.", "price": 10.0},
20
+ {"id": "B3", "name": "Fried Rice", "desc": "Wok-fried jasmine rice with egg, carrots, and peas. Comforting and aromatic.", "price": 8.0},
21
+ {"id": "B4", "name": "Grilled Fish", "desc": "Fillet of fish grilled with lemongrass and lime. Smoky and flavorful.", "price": 11.0},
22
+ {"id": "B5", "name": "Veggie Stir Fry", "desc": "Mixed vegetables sautéed in garlic soy sauce. Colorful and crunchy.", "price": 8.5},
23
+ ],
24
+ "Desserts": [
25
+ {"id": "C1", "name": "Mango Sticky Rice", "desc": "Sweet sticky rice with fresh mango and coconut cream. Thai classic dessert.", "price": 5.0},
26
+ {"id": "C2", "name": "Taro Cake", "desc": "Steamed taro root cake with a soft, chewy texture. Mildly sweet.", "price": 4.5},
27
+ {"id": "C3", "name": "Coconut Jelly", "desc": "Chilled coconut milk jelly, smooth and refreshing.", "price": 4.0},
28
+ {"id": "C4", "name": "Sweet Bean Soup", "desc": "Warm red bean soup with a hint of citrus zest. Sweet and comforting.", "price": 3.5},
29
+ {"id": "C5", "name": "Sesame Balls", "desc": "Glutinous rice balls filled with sweet bean paste, deep-fried until golden.", "price": 3.5},
30
+ ],
31
+ "Drinks": [
32
+ {"id": "D1", "name": "Lime Soda", "desc": "Sparkling soda with fresh lime juice. Zesty and refreshing.", "price": 2.5},
33
+ {"id": "D2", "name": "Iced Tea", "desc": "Chilled black tea with a splash of lemon. Lightly sweetened.", "price": 2.0},
34
+ {"id": "D3", "name": "Coconut Water", "desc": "Natural young coconut juice. Pure and hydrating.", "price": 3.0},
35
+ {"id": "D4", "name": "Soy Milk", "desc": "Sweetened soy milk, served cold. Nutty and smooth.", "price": 2.0},
36
+ {"id": "D5", "name": "Bottled Water", "desc": "Still mineral water in a glass bottle. Clean and classic.", "price": 1.5},
37
+ ],
38
+ },
39
  {"id": "A2", "name": "Dumplings", "desc": "Steamed pork dumplings", "price": 5.0},
40
  {"id": "A3", "name": "Salad", "desc": "Fresh vegetable salad", "price": 3.5},
41
  {"id": "A4", "name": "Tofu Skewers", "desc": "Grilled tofu with sauce", "price": 4.0},
 
64
  ],
65
  }
66
 
 
67
  # ========== 功能函数 ==========
68
  def record_time(start_time):
69
  duration = round(time.time() - start_time, 2)
 
94
  with gr.Tab(label=category):
95
  for item in items:
96
  with gr.Row():
97
+ with gr.Column(scale=1):
98
+ gr.Image(value="user_avatar.jpg", width=80, height=80, show_label=False, interactive=False)
99
+ with gr.Column(scale=5):
100
+ gr.Markdown(f"**{item['id']} - {item['name']}**
101
+
102
+ *{item['desc']}*
103
 
104
+ 💰 €{item['price']:.2f}")
105
+ submit_btn = gr.Button("✅ I have made my selection")
106
  output_box = gr.Textbox(label="", lines=3, interactive=False)
107
  submit_btn.click(fn=record_time, inputs=[gr.State(value=start_time)], outputs=output_box)
108
 
109
+ with gr.Accordion("📊 Admin Tools (optional)", open=False, visible=False):
110
  gr.Markdown("### View or Clear Recorded CSV Data")
111
  show_btn = gr.Button("📥 Show CSV Data")
112
  show_output = gr.Textbox(label="decision_times.csv content", lines=10)