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
import spoonacular #import modules required (not part of standard library, had to download)
import requests #""
api_key = spoonacular.API("5664423fc995470db93cccfc4f92ecd6") #registered an account with Spoonacular and got a key. Giving the external function the key as required input and assigning it to value for simplicity's sake
#food_input = input()
def ingredient_parsing(food_input):
"""this function analyses a sentences and returns the food within; usable in other function"""
return_value = api_key.parse_ingredients(food_input, servings=1) #calling parsing function from spoonacular whilst providing arguements
information = return_value.json() #response formatted and stored in a variable
print(information[0]['name']) #specifying which information we want [ie. the name of the food]
def food_joke():
"""this function returns a food joke from the bank spoonacular has"""
return_value = api_key.get_a_random_food_joke() #calls function, no parameters required
information = return_value.json() #response formatted and stored in a variable
print(information['text']) #specifying which information we want [ie. the text part of the joke itself]
def random_recipe():
"""returns random recipe"""
return_value = api_key.get_random_recipes() #calls function, no parameters required
information = return_value.json() #response formatted and stored in a variable
print(information['title'] + ": \n" + information['text']) #specifying which information we want [ie. the title of the recipe and actual recipe; colon and line seperation as formatting]
def wine_description():
"""given a wine's name, information is returned about it"""
wine_name = input("Enter wine name: ")
return_value = api_key.get_wine_description(wine_name) #wine name parameter given
information = return_value.json() #response formatted and stored in a variable
print(information['wine']) #specifies which information we want