nagasurendra commited on
Commit
2691732
·
verified ·
1 Parent(s): f94a797

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -10
app.py CHANGED
@@ -89,10 +89,11 @@ def filter_menu(preference):
89
 
90
  html_content = '<div style="padding: 0 10px; max-width: 1200px; margin: auto;">'
91
  for section, items in filtered_data.items():
92
- if items:
93
- html_content += f"<h2 style='text-align: center; margin-top: 10px;'>{section}</h2>"
94
- html_content += '<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; justify-content: center;">'
95
- for item in items:
 
96
  html_content += f"""
97
  <div style="border: 1px solid #ddd; border-radius: 10px; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); overflow: hidden;">
98
  <img src="{item.get('Image1__c', '')}" style="width: 100%; height: 250px; object-fit: cover;">
@@ -103,7 +104,9 @@ def filter_menu(preference):
103
  </div>
104
  </div>
105
  """
106
- html_content += '</div>'
 
 
107
  html_content += '</div>'
108
 
109
  if not any(filtered_data.values()):
@@ -116,11 +119,13 @@ with gr.Blocks() as app:
116
  with gr.Row():
117
  gr.HTML("<h1 style='text-align: center;'>Welcome to Biryani Hub</h1>")
118
 
119
- with gr.Row():
120
- preference = gr.Radio(choices=["All", "Veg", "Non-Veg"], label="Filter Preference", value="All")
121
-
122
- with gr.Row(visible=True) as menu_page:
123
- menu_output = gr.HTML()
 
 
124
 
125
  with gr.Row(visible=False) as signup_page:
126
  with gr.Column():
@@ -132,6 +137,10 @@ with gr.Blocks() as app:
132
  login_redirect = gr.Button("Go to Login")
133
  signup_output = gr.Textbox(label="Status")
134
 
 
 
 
 
135
  with gr.Row(visible=False) as footer:
136
  gr.HTML("<footer style='text-align: center;'>Thank you! Welcome again!</footer>")
137
 
@@ -150,6 +159,11 @@ with gr.Blocks() as app:
150
  content = filter_menu(preference)
151
  return content
152
 
 
 
 
 
 
153
  preference.change(handle_menu, [preference], menu_output)
154
 
155
  app.launch()
 
89
 
90
  html_content = '<div style="padding: 0 10px; max-width: 1200px; margin: auto;">'
91
  for section, items in filtered_data.items():
92
+ html_content += f"<h2 style='text-align: center; margin-top: 10px;'>{section}</h2>"
93
+ html_content += '<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; justify-content: center;">'
94
+ for _ in range(max(len(items), 4)): # Ensure at least 4 fixed slots
95
+ if items:
96
+ item = items.pop(0)
97
  html_content += f"""
98
  <div style="border: 1px solid #ddd; border-radius: 10px; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); overflow: hidden;">
99
  <img src="{item.get('Image1__c', '')}" style="width: 100%; height: 250px; object-fit: cover;">
 
104
  </div>
105
  </div>
106
  """
107
+ else:
108
+ html_content += "<div style='visibility: hidden; height: 250px;'></div>"
109
+ html_content += '</div>'
110
  html_content += '</div>'
111
 
112
  if not any(filtered_data.values()):
 
119
  with gr.Row():
120
  gr.HTML("<h1 style='text-align: center;'>Welcome to Biryani Hub</h1>")
121
 
122
+ with gr.Row(visible=True) as login_page:
123
+ with gr.Column():
124
+ login_email = gr.Textbox(label="Email")
125
+ login_password = gr.Textbox(label="Password", type="password")
126
+ login_button = gr.Button("Login")
127
+ signup_button = gr.Button("Go to Signup")
128
+ login_output = gr.Textbox(label="Status")
129
 
130
  with gr.Row(visible=False) as signup_page:
131
  with gr.Column():
 
137
  login_redirect = gr.Button("Go to Login")
138
  signup_output = gr.Textbox(label="Status")
139
 
140
+ with gr.Row(visible=False) as menu_page:
141
+ preference = gr.Radio(choices=["All", "Veg", "Non-Veg"], label="Filter Preference", value="All")
142
+ menu_output = gr.HTML()
143
+
144
  with gr.Row(visible=False) as footer:
145
  gr.HTML("<footer style='text-align: center;'>Thank you! Welcome again!</footer>")
146
 
 
159
  content = filter_menu(preference)
160
  return content
161
 
162
+ login_button.click(
163
+ handle_login, [login_email, login_password], [login_page, menu_page, footer, menu_output, login_output]
164
+ )
165
+ signup_button.click(lambda: (gr.update(visible=False), gr.update(visible=True)), None, [login_page, signup_page])
166
+ submit_signup.click(handle_signup, [signup_name, signup_email, signup_phone, signup_password], signup_output)
167
  preference.change(handle_menu, [preference], menu_output)
168
 
169
  app.launch()