Skip to main content

Custom WTForms field that handles hCaptcha display and validation.

Project description

WTForms hCaptcha

Custom WTForms field that handles hCaptcha display and validation.

Build Status PyPI Version GitHub License

hCaptcha is a CAPTCHA service that 'protects user privacy, rewards websites, and helps companies get their data labelled'. This helps to prevent spam on websites by adding a challenge to forms that are hard for computers to solve, but easy for humans to solve.

I wanted to use hCaptcha in one of my projects and although there are already Python libraries for working with hCaptcha, I had already used the WTForms ecosystem in that project so I wanted a drop in solution and as there were none at the time, I decided to create my own.

This is a modified version of wtforms-recaptcha by Artem Gluvchynsky to work with hCaptcha.

Installation

Use pip to install on all systems:

pip install wtforms-hcaptcha

Usage Example

This example creates an empty form with just a CAPTCHA field.

from wtforms.form import Form
from wtforms_hcaptcha import HcaptchaField

class MyForm(Form):
    captcha = HcaptchaField(site_key="YOUR_SITE_KEY_HERE", secret_key="YOUR_SECRET_KEY_HERE")

form = MyForm(request.form, captcha={
    # note this needs to be edited to get the correct IP address when using a reverse proxy
    "ip_address": request.remote_addr
})

if form.validate():
    print("You are not a robot!")
else:
    print(form.errors["captcha"])

Development Setup

This project uses Poetry to manage dependencies and packaging. Here are the installation instructions for Poetry.

Contributing

  1. Fork it (https://github.com/jake-walker/wtforms-hcaptcha/fork)
  2. Create your feature branch (git checkout -b feature/foobar)
  3. Commit your changes (git commit -am "Add some foobar")
  4. Push to the branch (git push origin feature/foobar)
  5. Create a new pull request

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

wtforms-hcaptcha-0.1.3.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

wtforms_hcaptcha-0.1.3-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file wtforms-hcaptcha-0.1.3.tar.gz.

File metadata

  • Download URL: wtforms-hcaptcha-0.1.3.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.12 Linux/5.8.0-1042-azure

File hashes

Hashes for wtforms-hcaptcha-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4e84e531e84ba4e90be757d473374775cb448eac47d39de043907240e220fa44
MD5 6d4dd65e0d322fa523ded843b13481bc
BLAKE2b-256 2b6f0be60031eb3ab2363211003be6c98795a9b43e702041041b76a05c4cdea9

See more details on using hashes here.

File details

Details for the file wtforms_hcaptcha-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: wtforms_hcaptcha-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.12 Linux/5.8.0-1042-azure

File hashes

Hashes for wtforms_hcaptcha-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cae73cc6eec660c287b7226234709bb6a39fae49b26336d5be243e56b48b747e
MD5 7c7aa07c4eb2c6fe81f0a65eed652f3a
BLAKE2b-256 9d2254bb03df361f7fb933cd0d199d500df722608cfaf86cfbaf98ccd21b6fcb

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