From 6935cefaf7eff1227259a35cb002f15fd3a56f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Tue, 13 May 2025 08:25:23 +0200 Subject: [PATCH] zmiany w acl --- app.py | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/app.py b/app.py index 921d189..f92906e 100644 --- a/app.py +++ b/app.py @@ -331,49 +331,41 @@ def create_admin_account(): @app.after_request def apply_headers(response): - gc = get_global_config() - + # Nagłówki niestandardowe custom_headers = app.config.get("ADD_HEADERS", {}) if isinstance(custom_headers, dict): for header, value in custom_headers.items(): response.headers[header] = str(value) + # Wykluczenia if response.status_code in (301, 302, 303, 307, 308): response.headers.pop("Vary", None) return response - if request.endpoint == 'robots': - return response - if 400 <= response.status_code < 500: response.headers["Cache-Control"] = "no-store" response.headers["Content-Type"] = "text/html; charset=utf-8" response.headers.pop("Vary", None) - elif 500 <= response.status_code < 600: response.headers["Cache-Control"] = "no-store" response.headers["Content-Type"] = "text/html; charset=utf-8" response.headers["Retry-After"] = "120" response.headers.pop("Vary", None) - elif request.path.startswith("/admin"): response.headers.pop("Vary", None) response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0" - else: response.headers["Vary"] = "Cookie, Accept-Encoding" - cache_control_value = getattr(gc, "cache_control", None) or "private, max-age=0" - response.headers["Cache-Control"] = cache_control_value + default_cache = app.config.get("CACHE_CONTROL_HEADER") or "private, max-age=0" + response.headers["Cache-Control"] = default_cache + # Blokowanie botów if app.config.get("BLOCK_BOTS", False): - cc = app.config.get("CACHE_CONTROL_HEADER") - if cc: - response.headers["Cache-Control"] = cc - response.headers.pop("Pragma", None) - else: - response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0" - response.headers["Pragma"] = app.config.get("PRAGMA_HEADER", "no-cache") - response.headers["X-Robots-Tag"] = app.config.get("ROBOTS_TAG", "noindex, nofollow, nosnippet, noarchive") + cc = app.config.get("CACHE_CONTROL_HEADER") or "no-store, no-cache, must-revalidate, max-age=0" + pragma = app.config.get("PRAGMA_HEADER") or "no-cache" + response.headers["Cache-Control"] = cc + response.headers["Pragma"] = pragma + response.headers["X-Robots-Tag"] = app.config.get("ROBOTS_TAG") or "noindex, nofollow, nosnippet, noarchive" return response