我正在创建一个Python Flask应用程序,并在下面创建了装饰器和视图.装饰器在查看索引时效果很好,但是当您注销并使用url_for索引重定向时,它会抛出一个构造函数.为什么会
def logged_in(fn):
def decorator():
if 'email' in session:
return fn()
else:
return render_template('not-allowed.html', page="index")
return decorator
@app.route('/')
@logged_in
def index():
email = session['email']
return render_template('index.html', auth=True, page="index", marks=marks)
@app.route('/sign-out')
def sign_out():
session.pop('email')
print(url_for('index'))
return redirect(url_for('index'))
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?错误是:BuildError: ('index', {}, None)