Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| # Menu data | |
| menu_items = [ | |
| { | |
| "name": "Crostini Caprese", | |
| "price": "₹260", | |
| "image": "static/CrostiniCaprese.jpg", | |
| "rating": "2.9", | |
| "reviews": "10", | |
| "description": "Tomatoes, olive oil, basil and mozzarella", | |
| "customizable": True, | |
| }, | |
| { | |
| "name": "Margherita Pizza", | |
| "price": "₹500", | |
| "image": "static/MargheritaPizza.jpg", | |
| "rating": "4.5", | |
| "reviews": "120", | |
| "description": "Classic margherita pizza with fresh tomatoes and basil", | |
| "customizable": False, | |
| }, | |
| ] | |
| # Gradio app | |
| with gr.Blocks() as app: | |
| gr.Markdown("## Recommended (20)") | |
| for item in menu_items: | |
| with gr.Row(): | |
| with gr.Column(scale=3): | |
| gr.Markdown(f""" | |
| **{item['name']}** | |
| {item['price']} | |
| ⭐ **{item['rating']}** ({item['reviews']}) | |
| _{item['description']}_ | |
| """) | |
| with gr.Column(scale=1, align="center"): | |
| gr.Image(value=item["image"], label="", elem_id="menu-image", show_label=False) | |
| gr.Button("ADD", elem_id="add-button") | |
| if item["customizable"]: | |
| gr.Markdown("Customisable", elem_id="customisable-text") | |
| # Add styles for better presentation | |
| gr.CSS(""" | |
| #menu-image { | |
| width: 100px; | |
| height: auto; | |
| border-radius: 10px; | |
| margin: 5px auto; | |
| } | |
| #add-button { | |
| background-color: #34c759; | |
| color: white; | |
| font-weight: bold; | |
| border-radius: 20px; | |
| padding: 10px; | |
| width: 100%; | |
| } | |
| #customisable-text { | |
| text-align: center; | |
| font-size: 12px; | |
| color: grey; | |
| } | |
| """) | |
| app.launch() | |