Пример #1
0
def recettes():
    if request.args.get("q"):
        app.logger.debug(request.args.get("q"))
        recipes = get_recipes()
        filtered_recipes = []
        for recipe in recipes:
            if re.search("^.*" + request.args.get("q") + ".*$", recipe["name"], re.IGNORECASE) and (recipe not in filtered_recipes):
                filtered_recipes.append(recipe)
            for ingredient in recipe["ingredients"]:
                if re.search("^.*" + request.args.get("q") + ".*$", ingredient, re.IGNORECASE) and (recipe not in filtered_recipes):
                    filtered_recipes.append(recipe)
        app.logger.debug(len(filtered_recipes))

        card_deck_nb = int(len(filtered_recipes) / 3)
        to_hide = 3-len(filtered_recipes) % 3
        if to_hide > 0:
            card_deck_nb += 1
        return render_template('recettes.html', recipes = filtered_recipes, card_deck_nb = card_deck_nb, to_hide = to_hide)

    else:
        recipes = get_recipes()
        card_deck_nb = int(len(recipes) / 3)
        to_hide = 3-len(recipes) % 3
        if to_hide > 0:
            card_deck_nb += 1
        return render_template('recettes.html', recipes = recipes, card_deck_nb = card_deck_nb, to_hide = to_hide)
Пример #2
0
def index():
    app.logger.debug('serving root URL /')
    recipes = get_recipes()
    front_page_recipes = []
    for i in range(1,4):
        front_page_recipes.append(recipes[-i])
    for i in range(3):
        front_page_recipes.append(recipes[i])
    #app.logger.debug(front_page_recipes)
    return render_template('index.html', week_recipes = front_page_recipes)
Пример #3
0
def reset():
    app.logger.debug('serving root URL /reset')
    reset_database()
    reset = True
    recipes = get_recipes()
    front_page_recipes = []
    for i in range(1,4):
        front_page_recipes.append(recipes[-i])
    for i in range(3):
        front_page_recipes.append(recipes[i])
    return render_template('index.html', reset = reset, week_recipes = front_page_recipes)
Пример #4
0
def srecipe(recipename):
    # if session.get("loggedin") == True:
    recipename = get_recipe_by_name()
    Drecipe = get_recipe_by_name()
    return render_template('srecipe.html', Drecipe=get_recipes())
Пример #5
0
def recipepage():
    # if session.get("loggedin") == True:
    return render_template('recipepage.html', Drecipe=get_recipes())