Skip to main content

A simple Flask extension to block AI crawlers.

Project description

flask-noAI

A simple Flask extension to block AI crawlers.

How it works

Flask-noAI adds certain rules to robots.txt expecting it to be respected, and if a violation of those rules is detected, content access is blocked.

How to use it

import flask_noai

flask_noai.noai(app)

Yes, it's this easy.

You can even do it like this:

from flask import Flask
from flask_noai import noai

app = noai(Flask(__name__))

Note: noai() does not need to be called at initialization of the app. It can be called later since it only registers route handlers:

...
...
...
app = Flask(__name__)
...
...
...
noai(app)
...
...
...

noai() returns back the original application to allow for chaining. noai() is basically the same as init_app() in most extensions except that noai() is mainly a route register rather than a "true" flask extension, which is why I chose the naming of noai() over init_app()!

Handling

  • If you want to have a custom message when unauthorised scraping was detected, use noai(..., on_detect="...")
  • If you want to return a non-200 code when it was detected, use noai(..., code=401) or other codes.
  • You can still add custom robots.txt by simply creating a route.
  • You should not make /robots, /robots/, or /robots.txt/ routes since they are handled by this extension.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_noai-1.1.0-py2.py3-none-any.whl (16.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file flask_noai-1.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: flask_noai-1.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.2

File hashes

Hashes for flask_noai-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0b1e95099b48315156104b505fc2a760b48e85dcb59e274e2ae77aad4368ac5d
MD5 afa09f9e0275cd96e7c00b78e0926075
BLAKE2b-256 93b9aa82e8e579e50d84cca4fb656eeb22e33a6a271f24b5fcac9be1f42e5d27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page