Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 烧瓶自动索引和延迟加载示例_Python 2.7_Flask_Flask Extensions - Fatal编程技术网

Python 2.7 烧瓶自动索引和延迟加载示例

Python 2.7 烧瓶自动索引和延迟加载示例,python-2.7,flask,flask-extensions,Python 2.7,Flask,Flask Extensions,我目前的脚本中包含以下内容: index = AutoIndex(app, browse_root=dir_to_index, add_url_rules=False) @app.route('/indexed') @app.route('/<path:path>') def autoindex(app=None, path='.'): return index.render_autoindex(path, template='indexed_dir.html', endp

我目前的脚本中包含以下内容:

index = AutoIndex(app, browse_root=dir_to_index, add_url_rules=False)

@app.route('/indexed')
@app.route('/<path:path>')
def autoindex(app=None, path='.'):
    return index.render_autoindex(path, template='indexed_dir.html', endpoint='.autoindex')
然后在我的脚本中:

app.add_url_rule('/indexed', view_func=views.autoindex)
然而,由于我有两个装饰师,我不确定如何最好地进行这件事。此外,我相信我可能必须处理应用程序/请求上下文


非常感谢您的帮助。提前感谢。

每次呼叫
路线
都只是另一次呼叫
在引擎盖下添加url\u规则

app.add_url_rule('/indexed', view_func=views.autoindex)
app.add_url_rule('/<path:path>', view_func=views.autoindex)
app.add\u url\u规则('/index',view\u func=views.autoindex)
app.add_url_规则('/',view_func=views.autoindex)

每次调用
路由
都只是另一次调用
在引擎盖下添加url\u规则

app.add_url_rule('/indexed', view_func=views.autoindex)
app.add_url_rule('/<path:path>', view_func=views.autoindex)
app.add\u url\u规则('/index',view\u func=views.autoindex)
app.add_url_规则('/',view_func=views.autoindex)