{"id":29176838,"url":"https://github.com/tn3w/flask-humanify","last_synced_at":"2025-07-01T17:33:02.317Z","repository":{"id":185330951,"uuid":"673332682","full_name":"tn3w/flask-Humanify","owner":"tn3w","description":"A strong bot protection system for Flask with many features: rate limiting, special rules for users, web crawler detection, and automatic bot detection.","archived":false,"fork":false,"pushed_at":"2025-06-27T20:09:08.000Z","size":96162,"stargazers_count":15,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-27T20:15:33.704Z","etag":null,"topics":["bot-protection","captcha","crawler","ddos","flask","python","rate-limiting","robot"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/flask-Humanify/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tn3w.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}},"created_at":"2023-08-01T11:48:37.000Z","updated_at":"2025-06-27T20:09:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"5b3ab7e9-a355-4276-874d-2c014c1ea4d1","html_url":"https://github.com/tn3w/flask-Humanify","commit_stats":null,"previous_names":["tn3w/flask_ddosify","tn3w/flask_captchaify","tn3w/flask_captcha"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/tn3w/flask-Humanify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tn3w%2Fflask-Humanify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tn3w%2Fflask-Humanify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tn3w%2Fflask-Humanify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tn3w%2Fflask-Humanify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tn3w","download_url":"https://codeload.github.com/tn3w/flask-Humanify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tn3w%2Fflask-Humanify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263007112,"owners_count":23398764,"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":["bot-protection","captcha","crawler","ddos","flask","python","rate-limiting","robot"],"created_at":"2025-07-01T17:30:51.885Z","updated_at":"2025-07-01T17:33:02.307Z","avatar_url":"https://github.com/tn3w.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eflask-Humanify\u003c/h1\u003e\n\u003cp align=\"center\"\u003eA strong bot protection system for Flask with many features: rate limiting, special rules for users, web crawler detection, and automatic bot detection.\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003ca rel=\"noreferrer noopener\" href=\"https://github.com/tn3w/flask-Humanify\"\u003e\u003cimg alt=\"Github\" src=\"https://img.shields.io/badge/Github-141e24.svg?\u0026style=for-the-badge\u0026logo=github\u0026logoColor=white\"\u003e\u003c/a\u003e  \u003ca rel=\"noreferrer noopener\" href=\"https://pypi.org/project/flask-Humanify/\"\u003e\u003cimg alt=\"PyPI\" src=\"https://img.shields.io/badge/PyPi-141e24.svg?\u0026style=for-the-badge\u0026logo=python\u0026logoColor=white\"\u003e\u003c/a\u003e  \u003ca rel=\"noreferrer noopener\" href=\"https://libraries.io/pypi/flask-Humanify\"\u003e\u003cimg alt=\"Libraries.io\" src=\"https://img.shields.io/badge/Libraries.io-141e24.svg?\u0026style=for-the-badge\u0026logo=npm\u0026logoColor=white\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\n```python\nfrom flask import Flask\nfrom flask_Humanify import Humanify\n\napp = Flask(__name__)\nhumanify = Humanify(app, challenge_type=\"one_click\", image_dataset=\"ai_dogs\")\n\n# Register the middleware to deny access to bots\nhumanify.register_middleware(action=\"challenge\")\n\n@app.route(\"/\")\ndef index():\n    \"\"\"\n    A route that is protected against bots and DDoS attacks.\n    \"\"\"\n    return \"Hello, Human!\"\n\nif __name__ == \"__main__\":\n    app.run()\n```\n\n### Advanced Protection Rules\n\nYou can customize bot protection with advanced filtering rules:\n\n```python\n# Protect specific endpoints with regex patterns\nhumanify.register_middleware(\n    action=\"challenge\",\n    endpoint_patterns=[\"api.*\", \"admin.*\"]  # Protect all API and admin endpoints\n)\n\n# Protect specific URL paths\nhumanify.register_middleware(\n    action=\"deny_access\",\n    url_patterns=[\"/sensitive/*\", \"/admin/*\"]  # Deny bot access to sensitive areas\n)\n\n# Exclude certain patterns from protection\nhumanify.register_middleware(\n    endpoint_patterns=[\"api.*\"],\n    exclude_patterns=[\"api.public.*\"]  # Don't protect public API endpoints\n)\n\n# Filter by request parameters\nhumanify.register_middleware(\n    request_filters={\n        \"method\": [\"POST\", \"PUT\", \"DELETE\"],  # Only protect write operations\n        \"args.admin\": \"true\",                # Only when admin=true query parameter exists\n        \"headers.content-type\": \"regex:application/json.*\"  # Match content type with regex\n    }\n)\n```\n\nNot using the middleware:\n\n```python\n@app.route(\"/\")\ndef index():\n    \"\"\"\n    A route that is protected against bots and DDoS attacks.\n    \"\"\"\n    if humanify.is_bot:\n        return humanify.challenge()\n    return \"Hello, Human!\"\n```\n\n## Usage\n\n### Installation\n\nInstall the package with pip:\n\n```bash\npip install flask-humanify --upgrade\n```\n\nImport the extension:\n\n```python\nfrom flask_humanify import Humanify\n```\n\nAdd the extension to your Flask app:\n\n```python\napp = Flask(__name__)\nhumanify = Humanify(app)\n```\n\n## Additional Features\n\n### Rate Limiting\n\nFlask-Humanify includes a rate limiting feature to protect your application from excessive requests:\n\n```python\nfrom flask import Flask\nfrom flask_humanify import Humanify, RateLimiter\n\napp = Flask(__name__)\nhumanify = Humanify(app)\n# Default: 10 requests per 10 seconds\nrate_limiter = RateLimiter(app)\n\n# Or customize rate limits\nrate_limiter = RateLimiter(app, max_requests=20, time_window=30)\n```\n\nThe rate limiter will automatically:\n\n- Track requests by IP address\n- Hash IPs for privacy\n- Redirect to a rate-limited page when limits are exceeded\n- Ignore rate limits for special pages like the rate-limited and access-denied pages\n\n### Error Handling\n\nFlask-Humanify provides a clean error handling system:\n\n```python\nfrom flask import Flask\nfrom flask_humanify import Humanify, ErrorHandler\n\napp = Flask(__name__)\nhumanify = Humanify(app)\n# Handle all standard HTTP errors\nerror_handler = ErrorHandler(app)\n\n# Use custom template with placeholders: EXCEPTION_TITLE, EXCEPTION_CODE, EXCEPTION_MESSAGE\nerror_handler = ErrorHandler(app, template_path=\"templates/error.html\")\n\n# Or handle only specific error codes\nerror_handler = ErrorHandler(app, errors=[404, 429, 500])\n\n# Or handle only specific error codes with a custom template\nerror_handler = ErrorHandler(app, errors={404: {\"template\": \"404.html\"}})\n```\n\nThe error handler:\n\n- Renders user-friendly error pages\n- Uses the custom exception.html template\n- Provides appropriate error messages and descriptions\n- Includes HTTP status codes and titles\n\n### Complete Example\n\nHere's a complete example combining all features:\n\n```python\nfrom flask import Flask\nfrom flask_humanify import Humanify, RateLimiter, ErrorHandler\n\napp = Flask(__name__)\n# Setup core protection\nhumanify = Humanify(app, challenge_type=\"one_click\", image_dataset=\"animals\")\nhumanify.register_middleware(action=\"challenge\")\n\n# Add rate limiting\nrate_limiter = RateLimiter(app, max_requests=15, time_window=60)\n\n# Add error handling\nerror_handler = ErrorHandler(app)\n\n@app.route(\"/\")\ndef index():\n    return \"Hello, Human!\"\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftn3w%2Fflask-humanify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftn3w%2Fflask-humanify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftn3w%2Fflask-humanify/lists"}