5

我一直在尝试通过 Flask-WTF 提供的 RecaptchaField 将 Google reCAPTCHA v3 集成到网站。我知道 reCAPTCHA v3 是 Google 新推出的,我想知道 Flask-WTF 是否支持它?

澄清:支持recaptcha v2。问题是,recaptcha v3 是否也受支持

4

1 回答 1

1

请查看也支持 Google 的 V3 的 Flask-Recaptcha:https ://github.com/rlid/flask-recaptcha

您可以像这样创建 Recaptcha 字段:

class Recaptcha3Form(FlaskForm):
    message = TextField(label="Message")
    recaptcha = Recaptcha3Field(action="TestAction", execute_on_load=True)
    submit = SubmitField(label="Submit")

并像这样渲染它:

@app.route("/v3", methods=["GET", "POST"])
def v3():
    form = Recaptcha3Form()
    if form.validate_on_submit():
        form.message.data = "[Success]" + form.message.data
    return render_template("demo.html", form=form)

请注意:我从烧瓶 recaptcha 文档中复制了代码

于 2019-12-06T14:39:41.883 回答