Spaces:
Build error
Build error
Update components/cards.py
Browse files- components/cards.py +7 -19
components/cards.py
CHANGED
|
@@ -6,27 +6,15 @@ def create_food_card(food_name):
|
|
| 6 |
nutrition = food_info["nutrition"]
|
| 7 |
portion_size = food_info["portion_size"]
|
| 8 |
|
| 9 |
-
#
|
| 10 |
card_html = f"""
|
| 11 |
<div class="food-card">
|
| 12 |
-
|
| 13 |
-
<
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
</
|
| 17 |
-
|
| 18 |
-
<!-- Bottom Section -->
|
| 19 |
-
<div class="card-content">
|
| 20 |
-
<div class="nutrition-details">
|
| 21 |
-
<h3>{food_name}</h3>
|
| 22 |
-
<table>
|
| 23 |
-
{"".join([f"<tr><td>{key}</td><td>{value}</td></tr>" for key, value in nutrition.items()])}
|
| 24 |
-
</table>
|
| 25 |
-
</div>
|
| 26 |
-
<div class="portion-details">
|
| 27 |
-
<p><strong>Portion Size:</strong> {portion_size}</p>
|
| 28 |
-
</div>
|
| 29 |
-
</div>
|
| 30 |
</div>
|
| 31 |
"""
|
| 32 |
return card_html
|
|
|
|
| 6 |
nutrition = food_info["nutrition"]
|
| 7 |
portion_size = food_info["portion_size"]
|
| 8 |
|
| 9 |
+
# Generate HTML for the card
|
| 10 |
card_html = f"""
|
| 11 |
<div class="food-card">
|
| 12 |
+
<img src="{image_src}" alt="{food_name}" class="food-image" />
|
| 13 |
+
<h3>{food_name}</h3>
|
| 14 |
+
<table class="nutrition-table">
|
| 15 |
+
{"".join([f"<tr><td>{key}</td><td>{value}</td></tr>" for key, value in nutrition.items()])}
|
| 16 |
+
</table>
|
| 17 |
+
<p><strong>Portion Size:</strong> {portion_size}</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
</div>
|
| 19 |
"""
|
| 20 |
return card_html
|