1 @app.route(‘/‘) 2 def index(): 3 flash(‘33333‘) 4 flash(‘44444‘) 5 flash(‘55555‘) 6 flash(‘66666‘) 7 if ‘username‘ in session: 8 return render_template(‘test.html‘) 9 10 return render_template(‘test.html‘)
// test.html
1 <body> 2 {% with messages = get_flashed_messages() %} 3 {% for message in messages %} 4 {{ message }} 5 {% endfor %} 6 {% endwith %} 7 </body>