Coder Social home page Coder Social logo

wtforms-hcaptcha's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.