Skip to content
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
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