flask中如何用按钮,再flash显示信息

如何点击按钮可以用flash闪现出python中的字符串或其他数据

<body>
    <form method = "post" action = "http://127.0.0.1:8000/login">
        <table>
            <tr>
                <td>Username</td>
                <td><input type = 'username' name = 'username'></td>
            </tr>
            <tr>
                <td>Password</td>
                <td><input type = 'password' name = 'password'></td>
            </tr>
            <tr>
                <td><input type = "submit" value = "Submit"></td>
            </tr>
        </table>
    </form>
    {% if error %}
        <p><strong>Error</strong>: {{ error }}</p>
    {% endif %}
</body>

<body>
    {% with messages = get_flashed_messages() %}
         {% if messages %}
               {% for message in messages %}
                    <p>{{ message }}</p>
               {% endfor %}
         {% endif %}
    {% endwith %}
<h3>Welcome!</h3>
<a href = "{{ url_for('login') }}">login</a>
</body>



from flask import Flask,render_template,request,flash,redirect,url_for
app = Flask(__name__,template_folder='./')
app.secret_key = 'random string'
@app.route('/')
def index():
    return render_template('index.html')
@app.route('/login', methods = ['GET', 'POST'])
def login():
    error = None
    if request.method == 'POST':
        if request.form['username'] != 'admin' or request.form['password'] != 'admin':
           error = 'Invalid username or password. Please try again!'
        else:
           flash('You were successfully logged in')
           return redirect(url_for('index'))
    return render_template('login.html', error = error)

if __name__ == '__main__':
    app.run(host='127.0.0.1',port=8000)

前两个网页,通过点击index.html中的按钮提交上传,闪现出来的会出现在login.html