Flashing messages in Flask App
Import flash
At the top of your 'views.py' add 'flash' to the 'Flask' import line, mine now looks like this:
from flask import Flask, Response, flash, redirect, url_for, request, session, abort
Edit main template
Now open your main HTML template, mine is called 'Layout.html'. It will currently include a 'div' tag with a class set to 'body-content', you can also find this tag by looking for the content block so look for '{% block content %}{% endblock %}'. Before this div add the following:
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class="alert alert-info alert-dismissible">
{% for message in messages %}
<strong>Error!</strong> {{message}}
<button type="button" class="close" data-dismiss="alert">×</button>
{% endfor %}
</div>
{% endif %}
{% endwith %}
This will get the messages created using 'flash' in the code, if messages are present it will create a 'div' for each message and set the class to be an 'alert'. The 'alert' will include a button to dismiss the 'alert'.