moar anti-AI measures

This commit is contained in:
mi
2025-11-15 15:49:34 +10:00
parent 14415dfcd2
commit 418ba6e4ba
2 changed files with 68 additions and 25 deletions

18
app.py
View File

@@ -19,6 +19,13 @@ app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'your-secret-key')
@app.after_request
def add_ai_blocking_headers(response):
"""Add headers to discourage AI scraping"""
response.headers['X-Robots-Tag'] = 'noai, noimageai'
return response
@app.context_processor
def inject_global_settings():
"""Make global settings available to all templates"""
@@ -321,6 +328,17 @@ Disallow: /
return Response(robots_txt, mimetype='text/plain')
@app.route('/tdmrep.json')
def tdm_reservation():
"""TDM (Text and Data Mining) reservation - signals AI training prohibition"""
return jsonify({
"tdm": {
"reservation": 1,
"policy": f"{SITE_URL}/terms"
}
})
@app.errorhandler(404)
def page_not_found(e):
"""404 error handler"""