Skip to main content

A hCaptcha extension for Flask based on flask-recaptcha

Project description

Flask-hCaptcha

Latest version released on PyPi Python package

A hCaptcha extension for Flask based on flask-recaptcha.

This repo is part of self-host video streaming project.


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()

Returns the HTML code to implement. But you can use {{ hcaptcha }} directly in your template

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

(c) 2021 Knugi (originally ReCaptcha by Mardix 2015)

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

Flask-hCaptcha-0.6.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

Flask_hCaptcha-0.6.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file Flask-hCaptcha-0.6.0.tar.gz.

File metadata

  • Download URL: Flask-hCaptcha-0.6.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for Flask-hCaptcha-0.6.0.tar.gz
Algorithm Hash digest
SHA256 d572de80818cfbb9400f36e7f394bf55c6e39b55878ac7e2eb54c28ca55f69ad
MD5 1c2ced16d15c0b6a0700a4692897c970
BLAKE2b-256 227e5f4d85a8600e03af750fb1b806941c1a131dc955bbd9741906f506708b2f

See more details on using hashes here.

File details

Details for the file Flask_hCaptcha-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for Flask_hCaptcha-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06730085002359e1ac6dc4dc2bd69f124ebe521e54ad474107554e4a5ab11aef
MD5 beedb1195075cb67237da9eebd4010f0
BLAKE2b-256 509222e41ea9eb654e0fc682f0db90e4834ac9e0506aca9557f869aca37262ff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page