Флэш-сообщение не отображается в приложении flask

#flask #web-applications #python-3.8

Вопрос:

Я разрабатываю веб-приложение для управления учетными записями, в котором каждый раз, когда пользователь создает запись о продажах, база данных будет обновляться, и должно быть отправлено флэш-сообщение, мой код соответствует приведенному ниже

 @app.route('/create_sales_record', methods=["POST", "GET"])
def defalt_create_sales_record():
    form = MyForm()
    if form.validate_on_submit():
        create_sales_record()
        flash(
        f'Sales record created at {datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}', 'success')
        return redirect(url_for('index'))
    if form.errors != {}:
        for errs in form.errors.values():
            flash(f'there were errors: {errs}')
    return render_template('form.html', form=form) 
 

и мой HTML-код:

     {% with messages = get_flashed_messages(with_categories=true) %}
        {%if messages %}
        {%for category, message in messages %}
        {%if category =='success'%}
        <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative" role="alert">
            <span class="block sm:inline">{{message}}</span>
            <span class="absolute top-0 bottom-0 right-0 px-4 py-3">
                <svg class="fill-current h-6 w-6 text-green-500" role="button" xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 20 20">
                    <title>Close</title>
                    <path
                        d="M14.348 14.849a1.2 1.2 0 0 1-1.697 0L10 11.819l-2.651 3.029a1.2 1.2 0 1 1-1.697-1.697l2.758-3.15-2.759-3.152a1.2 1.2 0 1 1 1.697-1.697L10 8.183l2.651-3.031a1.2 1.2 0 1 1 1.697 1.697l-2.758 3.152 2.758 3.15a1.2 1.2 0 0 1 0 1.698z" />
                </svg>
            </span>
        </div> {%else%}
        <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
            <span class="block sm:inline">{{message}}</span>
            <span class="absolute top-0 bottom-0 right-0 px-4 py-3">
                <svg class="fill-current h-6 w-6 text-red-500" role="button" xmlns="http://www.w3.org/2000/svg"
                    viewBox="0 0 20 20">
                    <title>Close</title>
                    <path
                        d="M14.348 14.849a1.2 1.2 0 0 1-1.697 0L10 11.819l-2.651 3.029a1.2 1.2 0 1 1-1.697-1.697l2.758-3.15-2.759-3.152a1.2 1.2 0 1 1 1.697-1.697L10 8.183l2.651-3.031a1.2 1.2 0 1 1 1.697 1.697l-2.758 3.152 2.758 3.15a1.2 1.2 0 0 1 0 1.698z" />
                </svg>
            </span>
        </div>
        {%endif%}
        {% endfor %}
        {% endif %}
        {% endwith %}
 

где я ошибаюсь?