Flask – Flash Message

app.py

from flask import flash, url_for, redirect

flash('Gagal Login')
return redirect(url_for('login'))

index.html

{% with messages = get_flashed_messages() %}
      {% if messages %}
            <div class="alert alert-danger" role="alert">
                <ul class=flashes>
                {% for message in messages %}
                  <li>{{ message }}</li>
                {% endfor %}
                </ul>
            </div>
      {% endif %}
{% endwith %}

Leave a Reply

Your email address will not be published. Required fields are marked *