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.txtby simply creating a route. - You should not make
/robots,/robots/, or/robots.txt/routes since they are handled by this extension.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b1e95099b48315156104b505fc2a760b48e85dcb59e274e2ae77aad4368ac5d
|
|
| MD5 |
afa09f9e0275cd96e7c00b78e0926075
|
|
| BLAKE2b-256 |
93b9aa82e8e579e50d84cca4fb656eeb22e33a6a271f24b5fcac9be1f42e5d27
|