zmiany w acl
This commit is contained in:
parent
1a62bbae2a
commit
6935cefaf7
28
app.py
28
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user