python-3.x - 如何在烧瓶应用程序工厂中免除 csrf 令牌
问题描述
我正在使用烧瓶的应用程序工厂,我正在尝试豁免一条路线。如果我csrf.exempt(team_routes.team_bp)
说它有效,但我只需要豁免team_bp.stat
路线。我努力了csrf.exempt(team_routes.team_bp.team_stats)
csrf = CSRFProtect()
def create_app()
....
csrf.init_app(app)
with app.app_context():
app.register_blueprint(team_route.team_bp)
我的team_route.py
档案
team_bp = Blueprint()
@team_route.route('/stat/')
@current_app.csrf.exempt
def team_stats():
添加@current_app.csrf.exempt
路线时出现以下错误Flask object has no attribute csrf
。如果我将其添加csrf_token()
到表单并提交它就可以了。但我想让stat
路线豁免
解决方案
推荐阅读
- python - 在 Python 中使用 URL 从 txt 中提取数据
- flutter - 在flutter中调用api后更新ModalBottomSheet
- bash - 使用 xargs 并行的多个 rsync - 最有效的目录结构通过
- python - 如何将更长的列表附加到数据框
- css - vue-simple-calendar“类”项目属性不起作用
- php - 为什么我们得到一个未定义索引的错误并且我们正在丢失我们的数据?
- c++ - “const Allocator& alloc = Allocator()”是什么意思?
- javascript - 如何在没有 useRef 的情况下定义我们不希望作为状态的变量
- python - 在一个特殊的序列中找到 f(n)
- javascript - 使用完全优化时,如何访问 Scala.js 中返回的元组的字段?