Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@
filtered_ingredients = [ingr for ingr in ingredients if ingr in INGREDIENTS]
ingredients_selected = st.multiselect("We found these ingredients (delete any you don't want to use)",
filtered_ingredients, default=filtered_ingredients)
ingredients_selected_formatted = ", ".join(ingredients_selected)

must_haves = st.multiselect('You can add more ingredients', INGREDIENTS)
must_haves_formatted = ", ".join(must_haves)
additional_ingredients = st.multiselect('You can add more ingredients', INGREDIENTS)

# Join recognized and additional ingredients together
for element in ingredients_selected:
additional_ingredients.append(element)
final_ingredients = ", ".join(additional_ingredients)

exclusions = st.multiselect("Anything you really don't like?", INGREDIENTS)
exclusions_formatted = ", ".join(exclusions)
Expand All @@ -63,8 +66,7 @@
diet = []

if st.button('get recipes'):
recipes = get_recipes(f"{ingredients_selected_formatted}, {must_haves_formatted}",
exclusions, cuisines_formatted, diet)
recipes = get_recipes(final_ingredients, exclusions, cuisines_formatted, diet)

if len(recipes) > 0:
show_recipes(recipes, 3)
Expand Down
3 changes: 2 additions & 1 deletion cookit_frontend/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def get_recipes(ingredients, exclusions, cuisine, diet):
# The number of results to skip (between 0 and 900).
# This is a bit risky in cases where less recipes were found than the offset value;
# --> the API is then returning no recipes.
"offset": offset}
#"offset": offset
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this for good reasons: to get (hopefully) different results every time the user is clicking the button. Without the offset, the user will always see the same recipes when no options are changed.

}

response = requests.get(BASE_URI, params)
print(params)
Expand Down
Loading