def api_get_recipes(): recipes = Recipes() recipes.ingredients = request.args.getlist('ingredients') recipes.fulltext = request.args.get('fullText') recipes.lang = request.args.get('lang') return jsonify(recipes=recipes.get_recipes(), not_found=recipes._not_founds), 200
def show_recipes(): auth = Auth() if auth.is_logged_in(): recipe_manager = Recipes() user = auth.get_current_user() recipes = recipe_manager.get_recipes(user['user_id']) print(recipes) print([recipe['recipe_id'] for recipe in recipes]) return render_template('recipes.html', recipes=recipes) return redirect(url_for('login'))
def show_recipes(): '''If logged in, show recipes for the current user. Otherwise, redirect to the Login page.''' # Hämtar mallen Recipies. recipes = Recipes() # Hämtar mallen Auth. auth = Auth() # Kollar om User är online. if auth.is_logged_in() == True: # I dont understand this.... user_id user_id = auth.get_current_user()['user_id'] # Test skriver ut user_id i terminalen. print(user_id) # Hämtar funktionen get_recipes. Med user_id. recipes = recipes.get_recipes(user_id) return render_template('recipes.html', recipes=recipes) else: return redirect(url_for('login'))