Skip to main content

Flask-hCaptcha

Latest version released on PyPi Python package

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

  1. Support Invisible Captcha
  2. Support the use of Language Codes

© 2021 Knugi © 2015 Mardix

Metadata

Release files for flask-hcaptcha 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-hcaptcha 0.7.2
File Size Uploaded
flask_hcaptcha-0.7.2.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flask-hcaptcha 0.7.2
File Interpreter ABI Platform
flask_hcaptcha-0.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / flask_hcaptcha-0.7.2.tar.gz

Download URL flask_hcaptcha-0.7.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e868faa9323b773dcb75914b7e11f8b029edc059c74bfdc8c90627087f3f5ec9
BLAKE2b-256 checksum
How to use checksums
3bf7670c24b9c3dd4517444c5d21f8abfdf08e2dd54d0fbfe88124a004d299cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 10, 2024.

Transparency log

Release files / flask_hcaptcha-0.7.2-py3-none-any.whl

Download URL flask_hcaptcha-0.7.2-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8db47a4a670595f2fc655c66be44aefd84b9dfcb57a44955b3e65fb5acb4b19a
BLAKE2b-256 checksum
How to use checksums
7f92ec6fb670580fd25d9de2c775b3f211c9704ba8ce4d833df305722cbdd9c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 10, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 release files

0.6.0

2 release files

0.5.4

2 release files

0.5.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page