{"id":20816632,"url":"https://github.com/alisharify7/flask_captcha2","last_synced_at":"2026-02-27T17:35:14.886Z","repository":{"id":166714260,"uuid":"642228132","full_name":"alisharify7/flask_captcha2","owner":"alisharify7","description":"Flask plugin to integrate Google captcha (version 2, 3) and local captcha (image, voice) with Flask applications ","archived":false,"fork":false,"pushed_at":"2025-05-03T05:21:35.000Z","size":668,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-03T06:18:56.823Z","etag":null,"topics":["captcha","flask","flask-capctha","flask-captcha-google","flask-captcha-plugin","flask-captcha2","flask-google-captcha","flask-local-captcha","flask-recaptcha","flask-security","google-captcha","google-recaptcha","image-captcha","python-captcha","python3","recaptcha"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/flask-captcha2","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alisharify7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-18T05:22:12.000Z","updated_at":"2025-05-03T05:21:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"5df6646a-7fe7-4ebc-8214-1986b05cf599","html_url":"https://github.com/alisharify7/flask_captcha2","commit_stats":null,"previous_names":["alisharify7/flask_captcha2"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisharify7%2Fflask_captcha2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisharify7%2Fflask_captcha2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisharify7%2Fflask_captcha2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisharify7%2Fflask_captcha2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alisharify7","download_url":"https://codeload.github.com/alisharify7/flask_captcha2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252150079,"owners_count":21702288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["captcha","flask","flask-capctha","flask-captcha-google","flask-captcha-plugin","flask-captcha2","flask-google-captcha","flask-local-captcha","flask-recaptcha","flask-security","google-captcha","google-recaptcha","image-captcha","python-captcha","python3","recaptcha"],"created_at":"2024-11-17T21:35:46.740Z","updated_at":"2025-10-11T20:39:19.496Z","avatar_url":"https://github.com/alisharify7.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"flask captcha2\n===============\n\n\u003cimg src=\"https://github.com/alisharify7/flask_captcha2/blob/main/docs/flask-captcha2-black.png?raw=true\"\u003e\n\nFlask plugin to integrate Google-captcha (version 2, 3) and local\ncaptcha (image, voice) with Flask applications\n\n\u003ca href=\"https://www.coffeete.ir/alisharify7\"\u003eDonate/Support [Optional]\u003c/a\u003e\n\n\u003cimg alt=\"GitHub repo size\" src=\"https://img.shields.io/github/repo-size/alisharify7/flask_captcha2\"\u003e \u003cimg alt=\"GitHub contributors\" src=\"https://img.shields.io/github/contributors/alisharify7/flask_captcha2\"\u003e \u003cimg alt=\"GitHub repo Licence\" src=\"https://img.shields.io/pypi/l/flask_captcha2\"\u003e\n\n[![Latest version](https://img.shields.io/pypi/v/Flask-captcha2)](https://pypi.python.org/pypi/Flask-captcha2)[![Supported python versions](https://img.shields.io/pypi/pyversions/Flask-captcha2)](https://pypi.python.org/pypi/flask_captcha2) [![Downloads](https://static.pepy.tech/badge/flask-captcha2)](https://pepy.tech/project/flask-captcha2) [![Downloads](https://static.pepy.tech/badge/flask-captcha2/month)](https://pepy.tech/project/flask-captcha2)\n\n\n🚀 demo\n------------------\n\n\u003cimg src=\"./docs/session-image-captcha-2.png\"\u003e\n\u003cimg src=\"./docs/session-image-captcha-1.png\"\u003e\n\u003cimg src=\"./docs/google-captcha.webp\" width=\"50%\"\u003e\n\n🔨 0.0 How to install:\n-------------------\n\n``` {.}\npip install -U flask_captcha2\n```\n\n🔧 0.1 how to use:\n---------------\n\n```python\nfrom flask import Flask\nfrom flask_captcha2 import FlaskCaptcha\n\napp = Flask(__name__)\n\n\n google_captcha2_config_list = {\n     \"CAPTCHA_PRIVATE_KEY\": \"hish !\",\n     \"CAPTCHA_PUBLIC_KEY\": \"hish !\",\n     'CAPTCHA_ENABLED': True,  # captcha status \u003cTrue, False\u003e\n     \"CAPTCHA_LOG\": True, # show captcha logs in console\n     \"CAPTCHA_LANGUAGE\": \"en\" # captcha language\n }\n\n google_captcha3_config_list = {\n     \"CAPTCHA_PRIVATE_KEY\": \"hish !\",\n     \"CAPTCHA_PUBLIC_KEY\": \"hish !\",\n     'CAPTCHA_ENABLED': True,  # captcha status \u003cTrue, False\u003e\n     \"CAPTCHA_SCORE\": 0.5,  #google captcha version3 works with scores\n     \"CAPTCHA_LOG\": True  # show captcha requests and logs in terminal \u003e stdout\n }\n\n captcha_manager = FlaskCaptcha(app=app)  # app is required\n # passing config list directly\n google_captcha2 = captcha_manager.get_google_captcha_v2(name='g-captcha2', conf=google_captcha2_config_list)\n google_captcha3 = captcha_manager.get_google_captcha_v3(name='g-captcha3', conf=google_captcha3_config_list)\n # Namespaces are important. Do not use repeated names and choose names with meaning.\n```\n\ngoogle captcha docs\nhttps://developers.google.com/recaptcha/docs/v3 v3\nhttps://developers.google.com/recaptcha/docs/display v2\n## example:\n\n```python\n# you can also pass nothing and it will be uses app.config for filling configs\n app.config.update(google_captcha3_config_list) # set configs in app.config\n MainCaptcha = FlaskCaptcha(app=app)\n # No need to send conf_list, it will be set automatically from app.config\n google_captcha2 = MainCaptcha.get_google_captcha_v2(name='g-captcha2')\n```\n\n0.2 how use in templates for rendering Captcha Widget:\n------------------------------------------------------\n\n#### Use \u003c captcha.render_captcha \u003e Filter to render a captcha in html\n\n##### -\u003e Remember namespaces argument in crating a captcha object\n\n```python\ngoogle_captcha2 = MainCaptcha.get_google_captcha_v2(name='g-captcha2') # name\ngoogle_captcha3 = MainCaptcha.get_google_captcha_v3(name='g-captcha3') # name\n```\n\nfor rendering a captcha width you should pass name to \u003c model_name \u003e in \u003c captcha.render_captcha \u003e\n\n## rendering Google Version 2 Captcha:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n    \u003ctitle\u003eCaptcha version 2\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\n \u003cform method=\"POST\" action=\"some-url\"\u003e\n     \u003cinput placeholder=\"username\" type=\"text\" name=\"username\" id=\"\"\u003e\n     \u003cbr\u003e\n     \u003cinput placeholder=\"password\" type=\"password\" name=\"password\" id=\"\"\u003e\n     \u003cbr\u003e\n     \u003cinput value=\"submit\" type=\"submit\"\u003e\n\n     {#\n        all available parameter for google captcha version 2:\n            model_name: required,\n            id: optional,\n            css_class: optional,\n            inline_css: optional,\n            js_event: optional,\n            dataset: optional,\n     #}\n\n\n     {{\n     captcha.render_captcha (\n            # [Required] namespace\n             model_name='g-captcha2',\n\n            # [Optional] add id to captcha widget\n             id='g-captcha-v2',\n\n            # [Optional] add css class to captcha widget\n            css_class='p-2 btn btn-primary',\n\n            # [Optional] add inline css to captcha widget\n            inline_css='font-size:10px;',\n\n            # [Optional] add dataset to captcha widget\n            dataset=\"data-checked='true';\"\n\n            # [Optional] add js event to captcha widget\n            js_event=\"onclick(alert('clicked!'))\",\n        )\n     }}\n\n \u003c/form\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Google captcha version 2 `render` parameters\n\n| parameter  | description                      | type | status     |\n|------------|----------------------------------|------|------------|\n| model_name | namespace                        | str  | `Required` |\n| id         | id of captcha widget in html     | str  | `Optional` |\n| css_class  | add css class to captcha widget  | str  | `Optional` |\n| inline_css | add inline css to captcha widget | str  | `Optional` |\n| dataset    | add dataset to captcha widget    | str  | `Optional` |\n| js_event   | add js event to captcha widget   | str  | `Optional` |\n\n## rendering Google Version 3 Captcha :\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n    \u003ctitle\u003eCaptcha version 3\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\n \u003cform method=\"POST\" action=\"/v3\" id=\"ParentForm\"\u003e # \u003c---- parent_form_id\n\n{# you can also use Flask-wtf forms #}\n \u003cinput placeholder=\"username\" type=\"text\" name=\"username\" id=\"\"\u003e\n \u003cbr\u003e\n \u003cinput placeholder=\"password\" type=\"password\" name=\"password\" id=\"\"\u003e\n \u003cbr\u003e\n {{\n     captcha.render_captcha (\n     # [Required] Namespace\n     model_name='g-captcha3'\n\n     # [Optional] add id to captcha widget\n     id=\"SubmitBtnForm\"\n\n     # [Optional] add custom css class to captcha widget\n     css_class='custom-class-name'\n\n     # [Optional] inline css of captcha widget\n     inline_css=\"background-color:blue; color:white; font-size:2rem;\"\n\n     # [Optional] add dataset to captcha widget\n     dataset=\"data-ok='true' data-test='test data set check' \"\n\n     # [Required] if of parent form\n     parent_form_id=\"ParentForm\"\n\n     # [Required] text content of the submit button\n     button_text=\"submit This Form\"\n\n     # [Optional] javascript event of captcha widget\n     js_event=\"onclick='alert('this is inline event');' \"\n\n     # [Optional] set visibility of captcha widget in bottom right corner,\n     # this parameter doesn't disable captcha, its only hidden the captcha in\n     # the page, but captcha still works\n     hide_badge=True\n     )\n }}\n \u003c/form\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Google captcha version 3 `render` parameters\n\n| parameter      | description                                                                                                                                                       | type | status     |\n|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|------------|\n| model_name     | namespace                                                                                                                                                         | str  | `Required` |\n| id             | id of captcha widget in html                                                                                                                                      | str  | `Optional` |\n| css_class      | add css class to captcha widget                                                                                                                                   | str  | `Optional` |\n| inline_css     | add inline css to captcha widget                                                                                                                                  | str  | `Optional` |\n| dataset        | add dataset to captcha widget                                                                                                                                     | str  | `Optional` |\n| js_event       | add js event to captcha widget                                                                                                                                    | str  | `Optional` |\n| parent_form_id | id of parent form element                                                                                                                                         | str  | `Required` |\n| hide_badge     | set visibility of captcha widget in bottom right corner, this parameter doesn't disable captcha, its only hidden the captcha in the page, but captcha still works | str  | `Optional` |\n| button_text    | text context of the captcha button                                                                                                                                | str  | `Required` |\n\n0.3 How to verify Captcha:\n-----------------------\n\nUse the is_verify method on captcha objects for validating a request that\ncontains a captcha\n\n```python\n@app.route(\"/g-v2-verify/\", methods=[\"POST\"])\ndef index():\n    # with is_verify method verify the captcha\n    if google_captcha2.is_verify():\n        return \"Captcha is ok.\"\n    else:\n        return \"Try again!\"\n\n@app.route(\"/g-v3-verify/\", methods=[\"POST\"])\ndef index():\n    # with the is_verify method verify the captcha\n    if google_captcha3.is_verify():\n        return \"Captcha is ok.\"\n    else:\n        return \"Try again!\"\n```\n\n\n## Star History\n\n[![Stargazers over time](https://starchart.cc/alisharify7/flask_captcha2.svg?variant=adaptive)](https://starchart.cc/alisharify7/flask_captcha2)\n\n### Version History:\n\n-   version 2.0.0 Released: May 18, 2023\n\n-   Changes: - None\n\n-   version 2.0.1 Released: June 9, 2023\n\n-   Changes:\n\n    \u003e -   Change FlaskCaptcha Class to FlaskCaptcha2\n    \u003e -   Fix bug in rendering captcha widget when captcha-enable was False\n\n-   version 3.0.0 Released: September 9, 2023\n\n-   Changes:\n\n    \u003e -   Change package structure\n    \u003e -   Add Captcha version 3 and fix some bugs in Captcha version 2\n\n-   version 3.0.4 Released: October 27, 2023\n-   Changes:\n\n    \u003e -   reformat/Refactor project structure\n    \u003e -   adding FlaskCaptcha Master class\n    \u003e -   adding getFlaskCaptcha3 method for getting google-captcha\n    \u003e     version 3\n    \u003e -   adding getFlaskCaptcha2 method for getting google-captcha version 2\n    \u003e -   adding namespacing for each captcha\n    \u003e -   adding the ability to create multiple captchas with different versions\n    \u003e -   adding Pytest base test\n\n\n- version 3.0.5 Released: July 21, 2024\n-   Changes:\n\n    \u003e -   reformat/Refactor code\n    \u003e -   rename render_captcha parameters\n\n- version 3.1.0 Released: September 28, 2024\n-   Changes:\n\n    \u003e -   reformat/Refactor code\n    \u003e -   Refactoring all method and function signatures to adhere to PEP8 input parameter naming conventions.\n    \u003e -   minor changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisharify7%2Fflask_captcha2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falisharify7%2Fflask_captcha2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisharify7%2Fflask_captcha2/lists"}