Download app.py from ajayx2006/kerthan: direct link, hf CLI and curl.
- Browser
- Download file 2.33 kB
-
https://huggingface.co/spaces/ajayx2006/kerthan/resolve/main/app.py
- Command line
-
hf download hf://spaces/ajayx2006/kerthan/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ajayx2006/kerthan/resolve/main/app.py
2.33 kB
| import gradio as gr | |
| order = [] | |
| prices = { | |
| "salad": 100, "chips & salsa": 150, "soup": 100, "thai chicken satay": 200, | |
| "tandoori lobster bites": 250, "panipuri shooters": 80, "veg fried fritters": 80, | |
| "pasta": 200, "burger": 120, "pizza": 170, "butter chicken with naan": 220, | |
| "thai green curry": 240, "mashed potato": 100, "mango lassi": 70, "water": 0, | |
| "iced tea": 40, "masala chai": 20, "sprite": 20, "pepsi": 20, "cold coffee": 40, | |
| "choco lava cake": 100, "ice cream": 50, "kulfi with saffron and pistachio": 80, | |
| "tiramisu": 120, "gulab jamun": 50, "cheesecake": 150, "cheese": 50 | |
| } | |
| def add_to_order(category, item, extras): | |
| item_cost = prices[item] | |
| if "cheese" in extras: | |
| item_cost += prices["cheese"] | |
| order.append((item.capitalize(), item_cost)) | |
| return order_summary() | |
| def order_summary(): | |
| summary = "YOUR ORDER:\n" | |
| total_cost = sum(cost for _, cost in order) | |
| for item, cost in order: | |
| summary += f"{item}: ₹{cost}\n" | |
| summary += f"Total cost: ₹{total_cost}" | |
| return summary | |
| appetizers = ["salad", "chips & salsa", "soup", "thai chicken satay", "tandoori lobster bites", "panipuri shooters", "veg fried fritters"] | |
| mains = ["pasta", "burger", "pizza", "butter chicken with naan", "thai green curry", "mashed potato"] | |
| drinks = ["mango lassi", "water", "iced tea", "masala chai", "sprite", "pepsi", "cold coffee"] | |
| desserts = ["choco lava cake", "ice cream", "kulfi with saffron and pistachio", "tiramisu", "gulab jamun", "cheesecake"] | |
| extras = ["cheese"] | |
| with gr.Blocks() as ui: | |
| gr.Markdown("## Welcome to Nomad Food Truck!") | |
| category = gr.Dropdown(["Appetizers", "Mains", "Drinks", "Desserts"], label="Select Category") | |
| item = gr.Dropdown([], label="Select Item") | |
| extra_options = gr.CheckboxGroup(extras, label="Add Extras", visible=False) | |
| 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) | |
| item.change(lambda x: gr.update(visible=(x in ["salad", "pasta", "burger", "choco lava cake"])), item, extra_options) | |
| add_btn = gr.Button("Add to Order") | |
| add_btn.click(add_to_order, inputs=[category, item, extra_options], outputs=gr.Textbox(label="Order Summary", value="")) | |
| ui.launch(share = True) | |