I modify the login of flaskr sample app, the first line get error. But www.html is in the template dir.
return redirect(url_for(\'www\'))
#return redirect(u
return redirect(url_for('www')) would work if you have a function somewhere else like this:
@app.route('/welcome')
def www():
return render_template('www.html')
url_for looks for a function, you pass it the name of the function you are wanting to call. Think of it like this:
@app.route('/login')
def sign_in():
for thing in login_routine:
do_stuff(thing)
return render_template('sign_in.html')
@app.route('/new-member')
def welcome_page():
flash('welcome to our new members')
flash('no cussing, no biting, nothing stronger than gin before breakfast')
return redirect(url_for('sign_in')) # not 'login', not 'sign_in.html'
You could also do return redirect('/some-url'), if that is easier to remember. It is also possible that what you want, given your first line, is just return render_template('www.html').
And also, not from shuaiyuancn's comment below, if you are using blueprints, url_for should be invoked as url_for('blueprint_name.func_name') Note you aren't passing the object, rather the string. See documentation here.