Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use ReCaptcha in blueprint #19

Open
paulocauca opened this issue Jun 19, 2020 · 3 comments
Open

How to use ReCaptcha in blueprint #19

paulocauca opened this issue Jun 19, 2020 · 3 comments

Comments

@paulocauca
Copy link

Hi Guys,
Sorry to open with a issue this question.

Can you help me implement the reCaptcha with blueprint ?

init.py
recaptcha = ReCaptcha() recaptcha.init_app(app)

html file

{{ recaptcha }}

how can I call recaptcha to verify in login.py

Thank you

@KnugiHK
Copy link

KnugiHK commented Jun 27, 2020

I did that by assigning the instance of ReCaptcha() in another module. Let's say

app.py (main)

import global # that's the "another" module
-------
global.recaptcha = ReCaptcha(app)
-------
@app.route("/"):
def index():
    return render_template("index.html", recaptcha=global.recaptcha.get_code())

html file

{{recaptcha}}

login.py

@login.route("/verify"):
def verify():
    if global.recaptcha.verify():
        -------

@paulocauca
Copy link
Author

Hi, Thanks , this global is a module that I install with pip ?

@KnugiHK
Copy link

KnugiHK commented Jul 1, 2020

No, the module "global" is just another python module file, you can rename to whatever you want.
E.g
variable.py #the global one
app.py
login.py

Another example:
glo.py #the global one
app.py
login.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants