Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,26 @@
|
|
| 1 |
-
|
| 2 |
-
from werkzeug.urls import url_parse, url_join # Correct way to import
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
data = request.get_json()
|
| 13 |
-
return jsonify({"message": "Data received", "data": data}), 200
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
+
def place_order(category, item):
|
| 4 |
+
return f"You have selected {item} from {category}. Your order has been placed!"
|
| 5 |
|
| 6 |
+
categories = {
|
| 7 |
+
"Starters": ["Soup", "Spring Rolls", "Garlic Bread"],
|
| 8 |
+
"Main Course": ["Pizza", "Burger", "Pasta"],
|
| 9 |
+
"Desserts": ["Ice Cream", "Brownie", "Cheesecake"]
|
| 10 |
+
}
|
| 11 |
|
| 12 |
+
def get_items(category):
|
| 13 |
+
return gr.update(choices=categories.get(category, []))
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
with gr.Blocks() as demo:
|
| 16 |
+
gr.Markdown("## Welcome to the Hugging Face Restaurant Menu")
|
| 17 |
+
|
| 18 |
+
category = gr.Dropdown(choices=list(categories.keys()), label="Select Category")
|
| 19 |
+
item = gr.Dropdown(choices=[], label="Select Item")
|
| 20 |
+
order_button = gr.Button("Place Order")
|
| 21 |
+
result = gr.Textbox(label="Order Confirmation")
|
| 22 |
+
|
| 23 |
+
category.change(get_items, inputs=[category], outputs=[item])
|
| 24 |
+
order_button.click(place_order, inputs=[category, item], outputs=[result])
|
| 25 |
+
|
| 26 |
+
demo.launch()
|