【发布时间】:2017-05-24 10:41:49
【问题描述】:
我正在尝试使用 Flask-WTF 的 CSRFProtect 扩展添加 CSRF 令牌保护。除此 CSRF 保护外,该应用未使用 WTForms。
我关注了the docs,但我收到“400 Bad Request The CSRF token is missing”。
from flask_wtf.csrf import CSRFProtect
csrf = CSRFProtect(app)
我将以下内容放在模板中(有表单或没有表单),但我得到了同样的错误。
<form method="post">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
</form>
【问题讨论】:
标签: python flask flask-wtforms