ajayx2006 commited on
Commit
90ef189
·
verified ·
1 Parent(s): 015d3b0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ order = []
4
+ prices = {
5
+ "salad": 100, "chips & salsa": 150, "soup": 100, "thai chicken satay": 200,
6
+ "tandoori lobster bites": 250, "panipuri shooters": 80, "veg fried fritters": 80,
7
+ "pasta": 200, "burger": 120, "pizza": 170, "butter chicken with naan": 220,
8
+ "thai green curry": 240, "mashed potato": 100, "mango lassi": 70, "water": 0,
9
+ "iced tea": 40, "masala chai": 20, "sprite": 20, "pepsi": 20, "cold coffee": 40,
10
+ "choco lava cake": 100, "ice cream": 50, "kulfi with saffron and pistachio": 80,
11
+ "tiramisu": 120, "gulab jamun": 50, "cheesecake": 150, "cheese": 50
12
+ }
13
+
14
+ def add_to_order(category, item, extras):
15
+ item_cost = prices[item]
16
+ if "cheese" in extras:
17
+ item_cost += prices["cheese"]
18
+ order.append((item.capitalize(), item_cost))
19
+ return order_summary()
20
+
21
+ def order_summary():
22
+ summary = "YOUR ORDER:\n"
23
+ total_cost = sum(cost for _, cost in order)
24
+ for item, cost in order:
25
+ summary += f"{item}: ₹{cost}\n"
26
+ summary += f"Total cost: ₹{total_cost}"
27
+ return summary
28
+
29
+ appetizers = ["salad", "chips & salsa", "soup", "thai chicken satay", "tandoori lobster bites", "panipuri shooters", "veg fried fritters"]
30
+ mains = ["pasta", "burger", "pizza", "butter chicken with naan", "thai green curry", "mashed potato"]
31
+ drinks = ["mango lassi", "water", "iced tea", "masala chai", "sprite", "pepsi", "cold coffee"]
32
+ desserts = ["choco lava cake", "ice cream", "kulfi with saffron and pistachio", "tiramisu", "gulab jamun", "cheesecake"]
33
+ extras = ["cheese"]
34
+
35
+ with gr.Blocks() as ui:
36
+ gr.Markdown("## Welcome to Nomad Food Truck!")
37
+ category = gr.Dropdown(["Appetizers", "Mains", "Drinks", "Desserts"], label="Select Category")
38
+ item = gr.Dropdown([], label="Select Item")
39
+ extra_options = gr.CheckboxGroup(extras, label="Add Extras", visible=False)
40
+
41
+ category.change(lambda x: gr.update(choices=appetizers if x == "Appetizers" else mains if x == "Mains" else drinks if x == "Drinks" else desserts), category, item)
42
+ item.change(lambda x: gr.update(visible=(x in ["salad", "pasta", "burger", "choco lava cake"])), item, extra_options)
43
+
44
+ add_btn = gr.Button("Add to Order")
45
+ add_btn.click(add_to_order, inputs=[category, item, extra_options], outputs=gr.Textbox(label="Order Summary", value=""))
46
+
47
+ ui.launch(share = True)