recipe_api = Blueprint('recipe_api', __name__,
url_prefix='/api/recipes')
# API docs https://flask-restful.readthedocs.io/en/latest/api.html
api = Api(recipe_api)
class UserAPI:
class _CRUD(Resource): # User API operation for Create, Read. THe Update, Delete methods need to be implemeented
def get(self, ingredients): # Create method
api_key = '84cfe45628de456c87a13a80b76f5bd8' # Replace with your Spoonacular API key
url = f"https://api.spoonacular.com/recipes/findByIngredients?apiKey={api_key}&ingredients=" + ingredients
response = requests.get(url)
if response.status_code == 200:
data = response.json()
return jsonify(data)
else:
#return jsonify({"error": "Failed to fetch recipes."}), response.status_code
return {'message': f'hello'}, 400