Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Remi/AllergenOptions.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
36 lines (32 sloc)
1.55 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def AllergenOptions(): | |
import requests # simplifies getting information from the API | |
query = True # variable used for the while loop | |
while query: | |
que = input('Do you have any intolerances/allergies (eg. dairy,seafood)?') | |
if que.upper() == 'YES': | |
allergens = input("Please list the things you are allergic to separated by a coma : ") | |
query = False | |
if que.upper() == "NO": | |
query = False | |
else: | |
break # go to main program | |
response = requests.get("https://api.spoonacular.com/recipes/complexSearch?apiKey=2c7d213247c34ccea25c72f9fe9053e9&intolerances=allergens&number=3&sort=random&instructionsRequired=true") | |
ingredient = response.json() | |
for i in ingredient["results"]: | |
print(i["title"]) | |
print(i["id"]) | |
idOfFood = i["id"] | |
question = input("Are you happy with this option?") | |
if question.upper() == "YES": | |
response2 = requests.get("https://api.spoonacular.com/recipes/" + str(idOfFood) + "/analyzedInstructions?apiKey=2c7d213247c34ccea25c72f9fe9053e9") | |
ingredient2 = response2.json() | |
########################### | |
#Francessca halped me with theese loops as they werent workink properly | |
for n in ingredient2[0]["steps"][0]["ingredients"]: | |
print(n["localizedName"]) | |
for x in ingredient2[0]["steps"]: | |
print(x["number"]) | |
print(x["step"]) | |
break | |
########################### | |
# go to main program | |