Flask-hCaptcha-0.6.0
توضیحات
A hCaptcha extension for Flask based on flask-recaptcha
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | Flask-hCaptcha-0.6.0 |
| نام | Flask-hCaptcha |
| نسخه کتابخانه | 0.6.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Knugi (originally ReCaptcha by Mardix) |
| ایمیل نویسنده | info@knugi.xyz |
| آدرس صفحه اصلی | https://github.com/KnugiHK/flask-hcaptcha/ |
| آدرس اینترنتی | https://pypi.org/project/Flask-hCaptcha/ |
| مجوز | MIT |
# Flask-hCaptcha
[](https://pypi.org/project/Flask-hCaptcha/)
[](https://github.com/KnugiHK/flask-hcaptcha/actions)
A hCaptcha extension for Flask based on flask-recaptcha.
This repo is part of [self-host video streaming project](https://github.com/users/KnugiHK/projects/3).
---
## 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](https://docs.hcaptcha.com/invisible)
2. Support the use of [Language Codes](https://docs.hcaptcha.com/languages)
---
(c) 2021 Knugi (originally ReCaptcha by Mardix 2015)
نیازمندی
| مقدار | نام |
|---|---|
| - | flask |
| - | requests |
نحوه نصب
نصب پکیج whl Flask-hCaptcha-0.6.0:
pip install Flask-hCaptcha-0.6.0.whl
نصب پکیج tar.gz Flask-hCaptcha-0.6.0:
pip install Flask-hCaptcha-0.6.0.tar.gz