'Flask FLash Message Not Popping Up

I have added Flash Messages to my Flask project and i am having an issue where my flash messages are not popping up when they are supposed too. In this case it should be popping up when i click the login and sign up button without meeting the requirements. To make Flash message i used my base.html file and Auth.file with my routes.

base.html

typ{% with messages = get_flashed_messages(with_categories=true) %} {% if
          messages %} {% for category, message in messages %} {% if category ==
          'error' %}
          <div class="alert alert-danger alter-dismissable fade show" role="alert">
            {{ message }}
            <button type="button" class="close" data-dismiss="alert">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          {% else %}
          <div class="alert alert-success alter-dismissable fade show" role="alert">
            {{ message }}
            <button type="button" class="close" data-dismiss="alert">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          {% endif %} {% endfor %} {% endif %} {% endwith %}

        <div class="container">
          {% block content %} {% endblock %}
        </div>e here

Auth.py

from operator import methodcaller
from xmlrpc.client import boolean
from flask import Blueprint, render_template, request, flash

auth = Blueprint('auth',__name__)

@auth.route('/login', methods=['GET', 'POST'])
def login():
    return render_template('login.html', boolean=True)

@auth.route('/logout')
def logout():
    return render_template('logout.html')

@auth.route('/sign-up', methods=['GET', 'POST'])
def sign_up():
    if request.method =='POST':
        email = request.form.get('email')
        firstName = request.form.get('firstName')
        password1 = request.form.get('password1')
        password2 = request.form.get('password2')
    
        if len(email) < 4:
            flash('Email must be greater than 3 characters.', category='error')
        elif len(firstName) < 2:
            flash('First name must be greater than 1 characters.', category='error')
        elif password1 != password2:
            flash('Passwords don\'t match.', category='error')
        elif len(password1) < 7:
            flash('Password is too short, must be greater then 7 characters.', category='error')
        else:
            flash('Account Created!', category='success')
            
    return render_template('sign_up.html')

I spent an hour combing through my code and matching it with what the tutorial has showing and i cant find anything wrong.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source