Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,9 +44,11 @@ def get_calories(meal:str) -> Union[str, None]:
|
|
| 44 |
if response.status_code == 200:
|
| 45 |
data = response.json()
|
| 46 |
if data['count'] > 0:
|
| 47 |
-
product
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
else:
|
| 51 |
return 'No data found'
|
| 52 |
else:
|
|
|
|
| 44 |
if response.status_code == 200:
|
| 45 |
data = response.json()
|
| 46 |
if data['count'] > 0:
|
| 47 |
+
for product in data['products']:
|
| 48 |
+
if 'energy-kcal_100g' in product.get('nutriments', {}):
|
| 49 |
+
calories = product['nutriments']['energy-kcal_100g']
|
| 50 |
+
return f"{calories} kcal per 100g"
|
| 51 |
+
return 'No data found'
|
| 52 |
else:
|
| 53 |
return 'No data found'
|
| 54 |
else:
|