Flask-Turnstile


NameFlask-Turnstile JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttp://github.com/Tech1k/flask-turnstile/
SummaryA Cloudflare Turnstile extension for Flask based on flask-recaptcha
upload_time2023-01-06 07:11:59
maintainer
docs_urlNone
authorKristian (originally ReCaptcha by Mardix)
requires_python
licenseMIT
keywords flask turnstile validate
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Flask-Turnstile
[![Latest version released on PyPi](https://img.shields.io/pypi/v/Flask-Turnstile.svg?style=flat&label=latest%20version)](https://pypi.org/project/Flask-Turnstile/)
[![PyPi monthly downloads](https://img.shields.io/pypi/dm/Flask-Turnstile)](https://img.shields.io/pypi/dm/Flask-Turnstile)
[![License: GPL v3](https://img.shields.io/badge/License-MIT-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Patreon](https://img.shields.io/badge/Donate-Patreon-orange.svg)](https://www.patreon.com/KristianKramer)
[![Buy Me A Coffee](https://img.shields.io/badge/donate-Buy%20Me%20a%20Coffee-yellow?label=Donate&style=flat-square)](https://www.buymeacoffee.com/KristianKramer)

A Cloudflare Turnstile extension for Flask based on flask-recaptcha.

---

## Install
```
pip install flask-turnstile
```

# Usage

### Implementation view.py
```
from flask import Flask
from flask_turnstile import Turnstile

app = Flask(__name__)
turnstile = Turnstile(app=app)

#or 

turnstile = Turnstile()
turnstile.init_app(app)
```

### In your template: **{{ turnstile }}**

Inside of the form you want to protect, include the tag: **{{ turnstile }}**

It will insert the code automatically

```
<form method="post" action="/submit">
    ... your field
    ... your field

    {{ turnstile }}

    [submit button]
</form>
```


### Verify the captcha

In the view that's going to validate the captcha

```
from flask import Flask
from flask_turnstile import Turnstile

app = Flask(__name__)
turnstile = Turnstile(app=app)

@route("/submit", methods=["POST"])
def submit():

    if turnstile.verify():
        # SUCCESS
        pass
    else:
        # FAILED
        pass
```


## Api

**turnstile.__init__(app, site_key, secret_key, is_enabled=True)**

**turnstile.get_code()**

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

**turnstile.verfiy()**

Returns bool

## In Template

Just include **{{ turnstile }}** wherever you want to show the captcha


## Config

Flask-Turnstile is configured through the standard Flask config API.
These are the available options:

**TURNSTILE_ENABLED**: Bool - True by default, when False it will bypass validation

**TURNSTILE_SITE_KEY** : Public key

**TURNSTILE_SECRET_KEY**: Private key

The following are **Optional** arguments.

```
TURNSTILE_ENABLED = True
TURNSTILE_SITE_KEY = ""
TURNSTILE_SECRET_KEY = ""
````

---

(c) 2015 Mardix
(c) 2023 Kristian

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/Tech1k/flask-turnstile/",
    "name": "Flask-Turnstile",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "flask,turnstile,validate",
    "author": "Kristian (originally ReCaptcha by Mardix)",
    "author_email": "kristian@kk.dev",
    "download_url": "https://files.pythonhosted.org/packages/47/50/f7424b2d2e1257345a9e35801613ce1a57fa6ed75ba758110d5bb904b63a/Flask-Turnstile-0.1.1.tar.gz",
    "platform": "any",
    "description": "# Flask-Turnstile\r\n[![Latest version released on PyPi](https://img.shields.io/pypi/v/Flask-Turnstile.svg?style=flat&label=latest%20version)](https://pypi.org/project/Flask-Turnstile/)\r\n[![PyPi monthly downloads](https://img.shields.io/pypi/dm/Flask-Turnstile)](https://img.shields.io/pypi/dm/Flask-Turnstile)\r\n[![License: GPL v3](https://img.shields.io/badge/License-MIT-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\r\n[![Patreon](https://img.shields.io/badge/Donate-Patreon-orange.svg)](https://www.patreon.com/KristianKramer)\r\n[![Buy Me A Coffee](https://img.shields.io/badge/donate-Buy%20Me%20a%20Coffee-yellow?label=Donate&style=flat-square)](https://www.buymeacoffee.com/KristianKramer)\r\n\r\nA Cloudflare Turnstile extension for Flask based on flask-recaptcha.\r\n\r\n---\r\n\r\n## Install\r\n```\r\npip install flask-turnstile\r\n```\r\n\r\n# Usage\r\n\r\n### Implementation view.py\r\n```\r\nfrom flask import Flask\r\nfrom flask_turnstile import Turnstile\r\n\r\napp = Flask(__name__)\r\nturnstile = Turnstile(app=app)\r\n\r\n#or \r\n\r\nturnstile = Turnstile()\r\nturnstile.init_app(app)\r\n```\r\n\r\n### In your template: **{{ turnstile }}**\r\n\r\nInside of the form you want to protect, include the tag: **{{ turnstile }}**\r\n\r\nIt will insert the code automatically\r\n\r\n```\r\n<form method=\"post\" action=\"/submit\">\r\n    ... your field\r\n    ... your field\r\n\r\n    {{ turnstile }}\r\n\r\n    [submit button]\r\n</form>\r\n```\r\n\r\n\r\n### Verify the captcha\r\n\r\nIn the view that's going to validate the captcha\r\n\r\n```\r\nfrom flask import Flask\r\nfrom flask_turnstile import Turnstile\r\n\r\napp = Flask(__name__)\r\nturnstile = Turnstile(app=app)\r\n\r\n@route(\"/submit\", methods=[\"POST\"])\r\ndef submit():\r\n\r\n    if turnstile.verify():\r\n        # SUCCESS\r\n        pass\r\n    else:\r\n        # FAILED\r\n        pass\r\n```\r\n\r\n\r\n## Api\r\n\r\n**turnstile.__init__(app, site_key, secret_key, is_enabled=True)**\r\n\r\n**turnstile.get_code()**\r\n\r\nReturns the HTML code to implement. But you can use\r\n**{{ turnstile }}** directly in your template\r\n\r\n**turnstile.verfiy()**\r\n\r\nReturns bool\r\n\r\n## In Template\r\n\r\nJust include **{{ turnstile }}** wherever you want to show the captcha\r\n\r\n\r\n## Config\r\n\r\nFlask-Turnstile is configured through the standard Flask config API.\r\nThese are the available options:\r\n\r\n**TURNSTILE_ENABLED**: Bool - True by default, when False it will bypass validation\r\n\r\n**TURNSTILE_SITE_KEY** : Public key\r\n\r\n**TURNSTILE_SECRET_KEY**: Private key\r\n\r\nThe following are **Optional** arguments.\r\n\r\n```\r\nTURNSTILE_ENABLED = True\r\nTURNSTILE_SITE_KEY = \"\"\r\nTURNSTILE_SECRET_KEY = \"\"\r\n````\r\n\r\n---\r\n\r\n(c) 2015 Mardix\r\n(c) 2023 Kristian\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Cloudflare Turnstile extension for Flask based on flask-recaptcha",
    "version": "0.1.1",
    "split_keywords": [
        "flask",
        "turnstile",
        "validate"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "505c4d8e2936a78625d905ced817d8fac0cc88d8f4cd43d32cf3bd77e9b63c8e",
                "md5": "a3968882299413fdc04420741a71385c",
                "sha256": "d5b97a5367489ac6368436e097e9e3b12645f39018f5d1747a9b58461384542b"
            },
            "downloads": -1,
            "filename": "Flask_Turnstile-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a3968882299413fdc04420741a71385c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4421,
            "upload_time": "2023-01-06T07:11:57",
            "upload_time_iso_8601": "2023-01-06T07:11:57.840388Z",
            "url": "https://files.pythonhosted.org/packages/50/5c/4d8e2936a78625d905ced817d8fac0cc88d8f4cd43d32cf3bd77e9b63c8e/Flask_Turnstile-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4750f7424b2d2e1257345a9e35801613ce1a57fa6ed75ba758110d5bb904b63a",
                "md5": "1e482b303c952c9b218404478b38575b",
                "sha256": "e97b51d684b59ffe1642eab92b3a8b75a57fd4cfc899baf1ee8eebffd9f05fbe"
            },
            "downloads": -1,
            "filename": "Flask-Turnstile-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1e482b303c952c9b218404478b38575b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4195,
            "upload_time": "2023-01-06T07:11:59",
            "upload_time_iso_8601": "2023-01-06T07:11:59.533065Z",
            "url": "https://files.pythonhosted.org/packages/47/50/f7424b2d2e1257345a9e35801613ce1a57fa6ed75ba758110d5bb904b63a/Flask-Turnstile-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-06 07:11:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Tech1k",
    "github_project": "flask-turnstile",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "flask-turnstile"
}
        
Elapsed time: 0.03966s