This commit is contained in:
Mateusz Gruszczyński
2026-05-08 20:51:05 +02:00
parent 51090a0eec
commit 673665d03d
7 changed files with 22 additions and 7 deletions

View File

@@ -30,7 +30,6 @@ def _wants_json_response() -> bool:
def register_error_pages(app: Flask) -> None:
# Notatka: własne strony błędów zastępują generyczne 404/500 i zachowują JSON dla API.
@app.errorhandler(404)
def not_found(error):
if _wants_json_response():
@@ -92,7 +91,6 @@ def create_app() -> Flask:
return url_for("static", filename=filename)
def frontend_asset_url(key: str) -> str:
# Notatka: helper przełącza szablony między CDN i lokalnymi plikami bez duplikowania logiki.
path = asset_path(key)
return path if path.startswith("http") else static_url(path)
@@ -108,12 +106,16 @@ def create_app() -> Flask:
@app.after_request
def cache_headers(response):
response.headers.pop('Content-Disposition', None)
if request.endpoint == "static":
response.headers.pop("Content-Disposition", None)
static_file = request.path.startswith("/static/")
tracker_icon = request.path.startswith("/static/tracker_favicons/")
if static_file and not tracker_icon:
response.headers["Cache-Control"] = "public, max-age=31536000, immutable"
else:
response.headers["Cache-Control"] = "no-store, private"
return response
from .routes.main import bp as main_bp