so write controller:
@app.route('/') def index(): flash('hello world!', 'success') return render_template('index.html')
then in template output flash messages this:
{%- messages = get_flashed_messages(with_categories=true) -%} {%- if messages -%} <ul class="flashes unstyled"> {%- category, message in messages -%} <li class="alert alert-{{ category }}"> <a class="close" data-dismiss="alert">×</a> {{ message }} </li> {%- endfor -%} </ul> {%- endif -%} {%- endwith %}
but issue 'message' category <li>
goes classes 'alert alert-message'
.
read docs , me did right, 'flash'
function ignoring second argument , uses default value 'message'
(instead of given me 'success').
i wonder if had issue , know how handle it?
edit: based on other comments , testing kwarg unnecessary.
based on docs @ http://flask.pocoo.org/docs/api/#message-flashing appears need use format. flash(message, category='message')
@app.route('/') def index(): flash('hello world!', category='success') return render_template('index.html')