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.txtby simply creating a route. - You should not make
/robots,/robots/, or/robots.txt/routes since they are handled by this extension.
Metadata
Release files for flask-noai 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_noai-1.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Release files / flask_noai-1.1.0-py2.py3-none-any.whl
| Download URL | flask_noai-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
0b1e95099b48315156104b505fc2a760b48e85dcb59e274e2ae77aad4368ac5d
|
|
BLAKE2b-256 checksum How to use checksums |
93b9aa82e8e579e50d84cca4fb656eeb22e33a6a271f24b5fcac9be1f42e5d27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.2
|