Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -60,15 +60,12 @@ def get_recipes(ingredients, max_calories=None, min_protein=None, max_fat=None,
|
|
60 |
# Extract recipes from the API response
|
61 |
recipes = response.json().get('results', [])
|
62 |
if recipes:
|
63 |
-
# Debugging: Print each recipe URL to verify it's correct
|
64 |
-
for recipe in recipes:
|
65 |
-
print(f"Recipe URL: https://spoonacular.com/recipes/{recipe['id']}") # Print URL for debugging
|
66 |
-
|
67 |
# Format and return the list of recipes as HTML links
|
68 |
-
|
69 |
[f'<a href="https://spoonacular.com/recipes/{recipe["id"]}" target="_blank">{recipe["title"]}</a>'
|
70 |
for recipe in recipes]
|
71 |
)
|
|
|
72 |
else:
|
73 |
return "No suitable recipes found."
|
74 |
else:
|
@@ -89,7 +86,7 @@ interface = gr.Interface(
|
|
89 |
gr.Number(label="Maximum fat (g, optional)"),
|
90 |
gr.Number(label="Maximum carbs (g, optional)"),
|
91 |
],
|
92 |
-
outputs=gr.HTML(label="Recipes"),
|
93 |
title="Estonian Recipe Search",
|
94 |
description="Enter ingredients in Estonian and set optional limits for calories, protein, fat, and carbs to find suitable recipes."
|
95 |
)
|
|
|
60 |
# Extract recipes from the API response
|
61 |
recipes = response.json().get('results', [])
|
62 |
if recipes:
|
|
|
|
|
|
|
|
|
63 |
# Format and return the list of recipes as HTML links
|
64 |
+
html_links = "<br>".join(
|
65 |
[f'<a href="https://spoonacular.com/recipes/{recipe["id"]}" target="_blank">{recipe["title"]}</a>'
|
66 |
for recipe in recipes]
|
67 |
)
|
68 |
+
return html_links
|
69 |
else:
|
70 |
return "No suitable recipes found."
|
71 |
else:
|
|
|
86 |
gr.Number(label="Maximum fat (g, optional)"),
|
87 |
gr.Number(label="Maximum carbs (g, optional)"),
|
88 |
],
|
89 |
+
outputs=gr.HTML(label="Recipes"), # Ensure output is HTML
|
90 |
title="Estonian Recipe Search",
|
91 |
description="Enter ingredients in Estonian and set optional limits for calories, protein, fat, and carbs to find suitable recipes."
|
92 |
)
|