我开始在Python Flask的所有路线中弹出这个问题:
@defaults.app.route('/<path:path>')
@forceUpdate
@FlaskLogin.login_required
@gzipped
def serve_page(path):
try:
resp = flask.send_from_directory(defaults.APP_STATIC, path)
return resp
except Exception:
return flask.render_template("index.html")
有没有更好的办法?你知道吗
forceUpdate
修饰符根据文件系统上的标志强制重定向。你知道吗
登录要求用户登录。你知道吗
还有Gzip。。。gzips回应。你知道吗
到目前为止,我有大约20条路线,有这么多装饰师的组合会越来越难看。你知道吗
您可以创建一个新的装饰器来应用其他装饰器:
然后只使用一个装饰器:
相关问题 更多 >
编程相关推荐