Set second argument when use flash() in view function:
flash('Something was wrong!', 'error')
In the template, set with_categories=true in get_flashed_messages(), then you get a list of tuples in the form of (message, category), so you can use category as a HTML class.
{% with messages = get_fl...