传递数据
# ...
# same as above
@app.route('/welcome/<name>')
def welcome(name):
return render_template('main.html', name=name)
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
# ...
# check for valid login, assign username
if valid:
return redirect(url_for('main_page', name=username))
else:
return redirect(url_for('login_error'))
else:
return render_template('login.html')