A hCaptcha extension for Flask based on flask-recaptcha
Project description
Flask-hCaptcha
A hCaptcha extension for Flask based on flask-recaptcha.
Flask-hCaptcha 0.6.0 will be the last version that support Python 2, 3.5 and 3.6.
Install
pip install flask-hcaptcha
Usage
Implementation view.py
from flask import Flask
from flask_hcaptcha import hCaptcha
app = Flask(__name__)
hcaptcha = hCaptcha(app)
#or
hcaptcha = hCaptcha()
hcaptcha.init_app(app)
In your template: {{ hcaptcha }}
Inside of the form you want to protect, include the tag: {{ hcaptcha }}
It will insert the code automatically
<form method="post" action="/submit">
... your field
... your field
{{ hcaptcha }}
[submit button]
</form>
Verify the captcha
In the view that's going to validate the captcha
from flask import Flask
from flask_hcaptcha import hCaptcha
app = Flask(__name__)
hcaptcha = hCaptcha(app)
@route("/submit", methods=["POST"])
def submit():
if hcaptcha.verify():
# SUCCESS
pass
else:
# FAILED
pass
API
hCaptcha.init(app, site_key, secret_key, is_enabled=True)
hCaptcha.get_code(dark_theme=False)
Returns the HTML code to implement. But you can use
{{ hcaptcha }} directly in your template. A dark
theme
can also be specified with dark_theme=True
.
hCaptcha.verify()
Returns bool
In Template
Just include {{ hcaptcha }} wherever you want to show the hcaptcha
Config
Flask-hCaptcha is configured through the standard Flask config API. These are the available options:
HCAPTCHA_ENABLED: Bool - True by default, when False it will bypass validation
HCAPTCHA_SITE_KEY : Public key
HCAPTCHA_SECRET_KEY: Private key
HCAPTCHA_ENABLED = True
HCAPTCHA_SITE_KEY = ""
HCAPTCHA_SECRET_KEY = ""
Todo
- Support Invisible Captcha
- Support the use of Language Codes
© 2021 Knugi © 2015 Mardix
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask_hcaptcha-0.7.2.tar.gz
.
File metadata
- Download URL: flask_hcaptcha-0.7.2.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
e868faa9323b773dcb75914b7e11f8b029edc059c74bfdc8c90627087f3f5ec9
|
|
MD5 |
914f76754e0aff80cc58c0ec7afc6f85
|
|
BLAKE2b-256 |
3bf7670c24b9c3dd4517444c5d21f8abfdf08e2dd54d0fbfe88124a004d299cc
|
Provenance
The following attestation bundles were made for flask_hcaptcha-0.7.2.tar.gz
:
Publisher:
python-publish.yml
on KnugiHK/flask-hcaptcha
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
flask_hcaptcha-0.7.2.tar.gz
-
Subject digest:
e868faa9323b773dcb75914b7e11f8b029edc059c74bfdc8c90627087f3f5ec9
- Sigstore transparency entry: 154484451
- Sigstore integration time:
-
Permalink:
KnugiHK/flask-hcaptcha@60b842205f813cb5c5a89235b73aa7993acb160d
-
Branch / Tag:
refs/tags/0.7.2
- Owner: https://github.com/KnugiHK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
python-publish.yml@60b842205f813cb5c5a89235b73aa7993acb160d
-
Trigger Event:
release
-
Statement type:
File details
Details for the file flask_hcaptcha-0.7.2-py3-none-any.whl
.
File metadata
- Download URL: flask_hcaptcha-0.7.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8db47a4a670595f2fc655c66be44aefd84b9dfcb57a44955b3e65fb5acb4b19a
|
|
MD5 |
8d7093f89f1f6af761beed7593e74a5a
|
|
BLAKE2b-256 |
7f92ec6fb670580fd25d9de2c775b3f211c9704ba8ce4d833df305722cbdd9c5
|
Provenance
The following attestation bundles were made for flask_hcaptcha-0.7.2-py3-none-any.whl
:
Publisher:
python-publish.yml
on KnugiHK/flask-hcaptcha
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
flask_hcaptcha-0.7.2-py3-none-any.whl
-
Subject digest:
8db47a4a670595f2fc655c66be44aefd84b9dfcb57a44955b3e65fb5acb4b19a
- Sigstore transparency entry: 154484452
- Sigstore integration time:
-
Permalink:
KnugiHK/flask-hcaptcha@60b842205f813cb5c5a89235b73aa7993acb160d
-
Branch / Tag:
refs/tags/0.7.2
- Owner: https://github.com/KnugiHK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
python-publish.yml@60b842205f813cb5c5a89235b73aa7993acb160d
-
Trigger Event:
release
-
Statement type: