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: 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) @app.errorhandler(404)
def not_found(error): def not_found(error):
if _wants_json_response(): if _wants_json_response():
@@ -92,7 +91,6 @@ def create_app() -> Flask:
return url_for("static", filename=filename) return url_for("static", filename=filename)
def frontend_asset_url(key: str) -> str: 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) path = asset_path(key)
return path if path.startswith("http") else static_url(path) return path if path.startswith("http") else static_url(path)
@@ -108,12 +106,16 @@ def create_app() -> Flask:
@app.after_request @app.after_request
def cache_headers(response): def cache_headers(response):
response.headers.pop('Content-Disposition', None) response.headers.pop("Content-Disposition", None)
if request.endpoint == "static": 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" response.headers["Cache-Control"] = "public, max-age=31536000, immutable"
else: else:
response.headers["Cache-Control"] = "no-store, private" response.headers["Cache-Control"] = "no-store, private"
return response return response
from .routes.main import bp as main_bp from .routes.main import bp as main_bp

View File

@@ -9,7 +9,6 @@ bp = Blueprint("main", __name__)
def _asset_url(key: str) -> str: def _asset_url(key: str) -> str:
# Notatka: API docs korzysta z tego samego przełącznika CDN/offline co reszta aplikacji.
path = asset_path(key) path = asset_path(key)
return path if path.startswith("http") else url_for("static", filename=path) return path if path.startswith("http") else url_for("static", filename=path)

View File

@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<rect x="14" y="20" width="36" height="30" rx="8" fill="#f8fafc" stroke="#0f172a" stroke-width="4"></rect>
<rect x="22" y="30" width="6" height="6" rx="3" fill="#0f172a"></rect>
<rect x="36" y="30" width="6" height="6" rx="3" fill="#0f172a"></rect>
<path d="M25 42h14" stroke="#0f172a" stroke-width="4" stroke-linecap="round"></path>
<path d="M32 20V10" stroke="#0f172a" stroke-width="4" stroke-linecap="round"></path>
<circle cx="32" cy="8" r="4" fill="#0f172a"></circle>
<path d="M14 34H8M56 34h-6" stroke="#0f172a" stroke-width="4" stroke-linecap="round"></path>
</svg>

After

Width:  |  Height:  |  Size: 647 B

View File

@@ -4,6 +4,8 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>pyTorrent {{ code }}</title> <title>pyTorrent {{ code }}</title>
<link rel="icon" href="/static/favicon.svg" type="image/svg+xml">
<link rel="shortcut icon" href="/static/favicon.svg" type="image/svg+xml">
<link href="{{ bootstrap_theme_url('default') }}" rel="stylesheet"> <link href="{{ bootstrap_theme_url('default') }}" rel="stylesheet">
<link href="{{ frontend_asset_url('fontawesome_css') }}" rel="stylesheet"> <link href="{{ frontend_asset_url('fontawesome_css') }}" rel="stylesheet">
<link href="{{ static_url('styles.css') }}" rel="stylesheet"> <link href="{{ static_url('styles.css') }}" rel="stylesheet">

View File

@@ -4,6 +4,8 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>pyTorrent</title> <title>pyTorrent</title>
<link rel="icon" href="/static/favicon.svg" type="image/svg+xml">
<link rel="shortcut icon" href="/static/favicon.svg" type="image/svg+xml">
<link id="bootstrapThemeStylesheet" href="{{ bootstrap_theme_url(prefs.bootstrap_theme if prefs else 'default') }}" rel="stylesheet"> <link id="bootstrapThemeStylesheet" href="{{ bootstrap_theme_url(prefs.bootstrap_theme if prefs else 'default') }}" rel="stylesheet">
<link href="{{ frontend_asset_url('fontawesome_css') }}" rel="stylesheet"> <link href="{{ frontend_asset_url('fontawesome_css') }}" rel="stylesheet">
<link href="{{ frontend_asset_url('flag_icons_css') }}" rel="stylesheet"> <link href="{{ frontend_asset_url('flag_icons_css') }}" rel="stylesheet">

View File

@@ -4,6 +4,8 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>pyTorrent login</title> <title>pyTorrent login</title>
<link rel="icon" href="/static/favicon.svg" type="image/svg+xml">
<link rel="shortcut icon" href="/static/favicon.svg" type="image/svg+xml">
<link href="{{ bootstrap_theme_url('default') }}" rel="stylesheet"> <link href="{{ bootstrap_theme_url('default') }}" rel="stylesheet">
<link href="{{ frontend_asset_url('fontawesome_css') }}" rel="stylesheet"> <link href="{{ frontend_asset_url('fontawesome_css') }}" rel="stylesheet">
<link href="{{ static_url('styles.css') }}" rel="stylesheet"> <link href="{{ static_url('styles.css') }}" rel="stylesheet">

View File

@@ -1,4 +1,3 @@
from pytorrent import create_app from pytorrent import create_app
# Note: Gunicorn imports this object; background Socket.IO tasks still start through create_app().
app = create_app() app = create_app()