{# templates/_flash_messages.html #} {# Check if there are any flashed messages #} {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {# Loop through messages and display them as Bootstrap alerts #} {% for category, message in messages %} {# Map Flask message categories (e.g., 'error', 'success', 'warning') to Bootstrap alert classes #} {% set alert_class = 'alert-info' %} {# Default class #} {% if category == 'error' or category == 'danger' %} {% set alert_class = 'alert-danger' %} {% elif category == 'success' %} {% set alert_class = 'alert-success' %} {% elif category == 'warning' %} {% set alert_class = 'alert-warning' %} {% endif %}