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?
Eugene-Chatbot/sav.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (25 sloc)
1.96 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
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 |