Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,26 @@
|
|
1 |
import pandas as pd
|
2 |
import gradio as gr
|
3 |
|
4 |
-
#
|
5 |
def load_menu(file_path="menu.xlsx"):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
if missing_columns:
|
12 |
-
raise ValueError(f"Missing columns in Excel file: {missing_columns}")
|
13 |
-
|
14 |
-
return menu_data
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
if preference != "All":
|
17 |
filtered_data = menu_data[menu_data["Category"] == preference]
|
18 |
else:
|
@@ -25,7 +33,7 @@ def load_menu(file_path="menu.xlsx"):
|
|
25 |
<div style="display: flex; align-items: center; border: 1px solid #ddd; border-radius: 8px; padding: 15px; margin-bottom: 10px; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);">
|
26 |
<div style="flex: 1; margin-right: 15px;">
|
27 |
<h3 style="margin: 0; font-size: 18px;">{item['Dish Name']}</h3>
|
28 |
-
<p style="margin: 5px 0; font-size: 16px; color: #888;"
|
29 |
<p style="margin: 5px 0; font-size: 14px; color: #555;">{item['Description']}</p>
|
30 |
</div>
|
31 |
<div style="flex-shrink: 0; text-align: center;">
|
@@ -38,6 +46,7 @@ def load_menu(file_path="menu.xlsx"):
|
|
38 |
|
39 |
# Gradio app definition
|
40 |
def app():
|
|
|
41 |
preferences = ["All", "Vegan", "Halal", "Guilt-Free"]
|
42 |
|
43 |
with gr.Blocks() as demo:
|
|
|
1 |
import pandas as pd
|
2 |
import gradio as gr
|
3 |
|
4 |
+
# Function to load menu data
|
5 |
def load_menu(file_path="menu.xlsx"):
|
6 |
+
try:
|
7 |
+
menu_data = pd.read_excel(file_path)
|
8 |
+
return menu_data
|
9 |
+
except FileNotFoundError:
|
10 |
+
raise FileNotFoundError("The menu.xlsx file was not found. Ensure it is in the same directory as app.py.")
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
# Function to filter the menu based on preference
|
13 |
+
def filter_menu(preference):
|
14 |
+
# Load menu data
|
15 |
+
menu_data = load_menu()
|
16 |
+
|
17 |
+
# Check for the required columns
|
18 |
+
required_columns = ["Category", "Dish Name", "Price", "Image URL", "Description"]
|
19 |
+
for col in required_columns:
|
20 |
+
if col not in menu_data.columns:
|
21 |
+
raise ValueError(f"Missing column in Excel file: {col}")
|
22 |
+
|
23 |
+
# Filter data based on preference
|
24 |
if preference != "All":
|
25 |
filtered_data = menu_data[menu_data["Category"] == preference]
|
26 |
else:
|
|
|
33 |
<div style="display: flex; align-items: center; border: 1px solid #ddd; border-radius: 8px; padding: 15px; margin-bottom: 10px; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);">
|
34 |
<div style="flex: 1; margin-right: 15px;">
|
35 |
<h3 style="margin: 0; font-size: 18px;">{item['Dish Name']}</h3>
|
36 |
+
<p style="margin: 5px 0; font-size: 16px; color: #888;">${item['Price']}</p>
|
37 |
<p style="margin: 5px 0; font-size: 14px; color: #555;">{item['Description']}</p>
|
38 |
</div>
|
39 |
<div style="flex-shrink: 0; text-align: center;">
|
|
|
46 |
|
47 |
# Gradio app definition
|
48 |
def app():
|
49 |
+
# Menu preferences
|
50 |
preferences = ["All", "Vegan", "Halal", "Guilt-Free"]
|
51 |
|
52 |
with gr.Blocks() as demo:
|