# Flask-hCaptcha
[![Latest version released on PyPi](https://img.shields.io/pypi/v/Flask-hCaptcha.svg?style=flat&label=latest%20version)](https://pypi.org/project/Flask-hCaptcha/)
[![Python package](https://github.com/KnugiHK/flask-hcaptcha/workflows/Python%20package/badge.svg)](https://github.com/KnugiHK/flask-hcaptcha/actions)
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](https://docs.hcaptcha.com/configuration#themes)
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](https://docs.hcaptcha.com/invisible)
2. Support the use of [Language Codes](https://docs.hcaptcha.com/languages)
---
© 2021 Knugi
© 2015 Mardix
Raw data
{
"_id": null,
"home_page": null,
"name": "flask-hcaptcha",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "flask, hcaptcha, validate, captcha",
"author": null,
"author_email": "Knugi <hello@knugi.com>",
"download_url": "https://files.pythonhosted.org/packages/3b/f7/670c24b9c3dd4517444c5d21f8abfdf08e2dd54d0fbfe88124a004d299cc/flask_hcaptcha-0.7.2.tar.gz",
"platform": null,
"description": "# Flask-hCaptcha\n[![Latest version released on PyPi](https://img.shields.io/pypi/v/Flask-hCaptcha.svg?style=flat&label=latest%20version)](https://pypi.org/project/Flask-hCaptcha/)\n[![Python package](https://github.com/KnugiHK/flask-hcaptcha/workflows/Python%20package/badge.svg)](https://github.com/KnugiHK/flask-hcaptcha/actions)\n\nA hCaptcha extension for Flask based on flask-recaptcha.\n\n**Flask-hCaptcha 0.6.0 will be the last version that support Python 2, 3.5 and 3.6.**\n\n---\n\n## Install\n\n pip install flask-hcaptcha\n\n# Usage\n\n### Implementation view.py\n\n from flask import Flask\n from flask_hcaptcha import hCaptcha\n\n app = Flask(__name__)\n hcaptcha = hCaptcha(app)\n \n #or \n \n hcaptcha = hCaptcha()\n hcaptcha.init_app(app)\n \n\n### In your template: **{{ hcaptcha }}**\n\nInside of the form you want to protect, include the tag: **{{ hcaptcha }}**\n\nIt will insert the code automatically\n\n\n <form method=\"post\" action=\"/submit\">\n ... your field\n ... your field\n\n {{ hcaptcha }}\n\n [submit button]\n </form>\n\n\n### Verify the captcha\n\nIn the view that's going to validate the captcha\n\n from flask import Flask\n from flask_hcaptcha import hCaptcha\n\n app = Flask(__name__)\n hcaptcha = hCaptcha(app)\n\n @route(\"/submit\", methods=[\"POST\"])\n def submit():\n\n if hcaptcha.verify():\n # SUCCESS\n pass\n else:\n # FAILED\n pass\n\n\n## API\n\n**hCaptcha.__init__(app, site_key, secret_key, is_enabled=True)**\n\n**hCaptcha.get_code(dark_theme=False)**\n\nReturns the HTML code to implement. But you can use\n**{{ hcaptcha }}** directly in your template. A [dark\ntheme](https://docs.hcaptcha.com/configuration#themes)\ncan also be specified with `dark_theme=True`.\n\n**hCaptcha.verify()**\n\nReturns bool\n\n## In Template\n\nJust include **{{ hcaptcha }}** wherever you want to show the hcaptcha\n\n\n## Config\n\nFlask-hCaptcha is configured through the standard Flask config API.\nThese are the available options:\n\n**HCAPTCHA_ENABLED**: Bool - True by default, when False it will bypass validation\n\n**HCAPTCHA_SITE_KEY** : Public key\n\n**HCAPTCHA_SECRET_KEY**: Private key\n\n HCAPTCHA_ENABLED = True\n HCAPTCHA_SITE_KEY = \"\"\n HCAPTCHA_SECRET_KEY = \"\"\n\n## Todo\n1. Support [Invisible Captcha](https://docs.hcaptcha.com/invisible)\n2. Support the use of [Language Codes](https://docs.hcaptcha.com/languages)\n\n---\n\n\u00a9 2021 Knugi \n\u00a9 2015 Mardix \n\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A hCaptcha extension for Flask based on flask-recaptcha",
"version": "0.7.2",
"project_urls": {
"Homepage": "https://github.com/KnugiHK/flask-hcaptcha/"
},
"split_keywords": [
"flask",
" hcaptcha",
" validate",
" captcha"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7f92ec6fb670580fd25d9de2c775b3f211c9704ba8ce4d833df305722cbdd9c5",
"md5": "8d7093f89f1f6af761beed7593e74a5a",
"sha256": "8db47a4a670595f2fc655c66be44aefd84b9dfcb57a44955b3e65fb5acb4b19a"
},
"downloads": -1,
"filename": "flask_hcaptcha-0.7.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8d7093f89f1f6af761beed7593e74a5a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 4794,
"upload_time": "2024-12-10T15:23:19",
"upload_time_iso_8601": "2024-12-10T15:23:19.050103Z",
"url": "https://files.pythonhosted.org/packages/7f/92/ec6fb670580fd25d9de2c775b3f211c9704ba8ce4d833df305722cbdd9c5/flask_hcaptcha-0.7.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3bf7670c24b9c3dd4517444c5d21f8abfdf08e2dd54d0fbfe88124a004d299cc",
"md5": "914f76754e0aff80cc58c0ec7afc6f85",
"sha256": "e868faa9323b773dcb75914b7e11f8b029edc059c74bfdc8c90627087f3f5ec9"
},
"downloads": -1,
"filename": "flask_hcaptcha-0.7.2.tar.gz",
"has_sig": false,
"md5_digest": "914f76754e0aff80cc58c0ec7afc6f85",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 4536,
"upload_time": "2024-12-10T15:23:21",
"upload_time_iso_8601": "2024-12-10T15:23:21.383896Z",
"url": "https://files.pythonhosted.org/packages/3b/f7/670c24b9c3dd4517444c5d21f8abfdf08e2dd54d0fbfe88124a004d299cc/flask_hcaptcha-0.7.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-10 15:23:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "KnugiHK",
"github_project": "flask-hcaptcha",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "flask-hcaptcha"
}