October 2018
Intermediate to advanced
332 pages
8h 9m
English
The get_flashed_messages() function returns a list of all the messages passed through the flash() function in Flask. The flash function is a simple function that queues messages—which consist of Python tuples of (category, message) phrases—for the get_flashed_messages function to consume, as shown in the following code:
{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %} <div class="alert alert-{{ category }} alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria- label="Close"><span aria-hidden="true">×</span></button> {{ message }} </div> {% endfor %} {% endif %}{% endwith %}
Proper feedback ...