nagasurendra commited on
Commit
118d5fd
·
verified ·
1 Parent(s): 84aa492

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -8,7 +8,7 @@ def load_menu():
8
  except Exception as e:
9
  raise ValueError(f"Error loading menu file: {e}")
10
 
11
- # Function to filter and display menu items
12
  def filter_menu(preference):
13
  menu_data = load_menu()
14
  if preference == "Halal/Non-Veg":
@@ -20,7 +20,7 @@ def filter_menu(preference):
20
  else: # Default to "All"
21
  filtered_data = menu_data
22
 
23
- # Generate HTML for the menu
24
  html_content = ""
25
  for _, item in filtered_data.iterrows():
26
  html_content += f"""
@@ -38,11 +38,12 @@ def filter_menu(preference):
38
  """
39
  return html_content
40
 
41
- # Main Gradio app
42
  def app():
43
  with gr.Blocks(css="style.css") as demo:
44
- # Menu Filters
45
  gr.Markdown("## Dynamic Menu with Preferences")
 
 
46
  preference_selector = gr.Radio(
47
  choices=["All", "Vegetarian", "Halal/Non-Veg", "Guilt-Free"],
48
  value="All",
@@ -50,7 +51,7 @@ def app():
50
  )
51
  menu_output = gr.HTML(value=filter_menu("All"))
52
 
53
- # Modal Logic via HTML
54
  modal_logic = gr.HTML("""
55
  <div id="modal" class="modal">
56
  <div class="modal-content">
@@ -85,7 +86,7 @@ def app():
85
  </script>
86
  """)
87
 
88
- # App Layout
89
  with gr.Row():
90
  preference_selector.change(filter_menu, inputs=[preference_selector], outputs=[menu_output])
91
  with gr.Row():
 
8
  except Exception as e:
9
  raise ValueError(f"Error loading menu file: {e}")
10
 
11
+ # Function to filter menu items
12
  def filter_menu(preference):
13
  menu_data = load_menu()
14
  if preference == "Halal/Non-Veg":
 
20
  else: # Default to "All"
21
  filtered_data = menu_data
22
 
23
+ # Generate HTML for menu items
24
  html_content = ""
25
  for _, item in filtered_data.iterrows():
26
  html_content += f"""
 
38
  """
39
  return html_content
40
 
41
+ # Main Gradio App
42
  def app():
43
  with gr.Blocks(css="style.css") as demo:
 
44
  gr.Markdown("## Dynamic Menu with Preferences")
45
+
46
+ # Menu and Filter Section
47
  preference_selector = gr.Radio(
48
  choices=["All", "Vegetarian", "Halal/Non-Veg", "Guilt-Free"],
49
  value="All",
 
51
  )
52
  menu_output = gr.HTML(value=filter_menu("All"))
53
 
54
+ # Modal Logic Injected via HTML
55
  modal_logic = gr.HTML("""
56
  <div id="modal" class="modal">
57
  <div class="modal-content">
 
86
  </script>
87
  """)
88
 
89
+ # Layout
90
  with gr.Row():
91
  preference_selector.change(filter_menu, inputs=[preference_selector], outputs=[menu_output])
92
  with gr.Row():