Skip to Content
Mastering Flask Web Development - Second Edition
book

Mastering Flask Web Development - Second Edition

by Daniel Gaspar, Jack Stouffer
October 2018
Intermediate to advanced
332 pages
8h 9m
English
Packt Publishing
Content preview from Mastering Flask Web Development - Second Edition

The get_flashed_messages() function

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">&times;</span></button>            {{ message }}        </div>        {% endfor %}    {% endif %}{% endwith %}

Proper feedback ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Flask Web Development, 2nd Edition

Flask Web Development, 2nd Edition

Miguel Grinberg
Flask Web Development

Flask Web Development

Miguel Grinberg

Publisher Resources

ISBN: 9781788995405Supplemental Content