Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from components.cards import create_food_card
|
| 3 |
+
from components.data import FOOD_DATA
|
| 4 |
+
|
| 5 |
+
# Function to render a card based on selected item
|
| 6 |
+
def display_card(food_name):
|
| 7 |
+
return create_food_card(food_name)
|
| 8 |
+
|
| 9 |
+
# Dropdown with food items
|
| 10 |
+
food_items = list(FOOD_DATA.keys())
|
| 11 |
+
|
| 12 |
+
# Gradio app interface
|
| 13 |
+
with gr.Blocks(css="styles.css") as app:
|
| 14 |
+
gr.Markdown("# 🍽️ Indian & Chinese Food Nutritional Information")
|
| 15 |
+
gr.Markdown("### Click on a food item to explore its nutritional details.")
|
| 16 |
+
with gr.Row():
|
| 17 |
+
food_dropdown = gr.Dropdown(label="Select a Dish", choices=food_items)
|
| 18 |
+
display_area = gr.HTML()
|
| 19 |
+
|
| 20 |
+
# Event to update the display area with card
|
| 21 |
+
food_dropdown.change(display_card, inputs=food_dropdown, outputs=display_area)
|
| 22 |
+
|
| 23 |
+
# Run the app
|
| 24 |
+
app.launch()
|