Subbu1304 commited on
Commit
312277d
·
verified ·
1 Parent(s): 3651d19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -12
app.py CHANGED
@@ -1,16 +1,26 @@
1
- from flask import Flask, request, jsonify, render_template
2
- from werkzeug.urls import url_parse, url_join # Correct way to import
3
 
4
- app = Flask(__name__)
 
5
 
6
- @app.route("/")
7
- def index():
8
- return render_template("index.html")
 
 
9
 
10
- @app.route("/submit", methods=["POST"])
11
- def submit():
12
- data = request.get_json()
13
- return jsonify({"message": "Data received", "data": data}), 200
14
 
15
- if __name__ == "__main__":
16
- app.run(debug=True)
 
 
 
 
 
 
 
 
 
 
 
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()