相关疑难解决方法(0)

用相同的装饰器"烧瓶"路由到view_func

假设我有这条路线:

app.add_url_rule('/',
                  view_func=index,
                  methods=['GET'])

app.add_url_rule('login',
                  view_func=login,
                  methods=['GET', 'POST'])

@validate_access()
def index():
    #......

@validate_access()
def login():
    #......
Run Code Online (Sandbox Code Playgroud)

我有2个端点与相同的装饰"@validate_access".当我运行这个代码时,我得到了

AssertionError: View function mapping is overwriting an existing endpoint function:    wrapperAssertionError: View function mapping is overwriting an existing endpoint function: wrapper
Run Code Online (Sandbox Code Playgroud)

我不知道它是不是一个bug.但如果有解决方案,请通知我.

谢谢 :)

python decorator flask python-2.7

3
推荐指数
1
解决办法
3445
查看次数

标签 统计

decorator ×1

flask ×1

python ×1

python-2.7 ×1