From 1d0ef1535f735517073996ce74fe357c8077ee9c Mon Sep 17 00:00:00 2001 From: pablusha Date: Mon, 11 Aug 2025 13:58:54 +0300 Subject: [PATCH] cool patch with 5 lines of code --- README.md | 2 +- main.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 492abce..7288ce8 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ pip install aiofiles ## preset.html -обычный html документ, являющийся шаблоном для листинга каталога +обычный html документ, являющийся шаблоном для листинга каталога. если в директории будет находиться preset.html, сервер будет использовать именно его. в противном случае - тот, который указан в конфиге. ### теги пресета diff --git a/main.py b/main.py index 69e1bbe..1537b58 100644 --- a/main.py +++ b/main.py @@ -108,7 +108,11 @@ class WebServer: elif os.path.isdir(file_path): resp = "" - async with aiofiles.open(config.preset_file, "r", encoding="utf-8") as f: + if os.path.isfile(os.path.join(file_path, "preset.html")): + preset_file = os.path.join(file_path, "preset.html") + else: + preset_file = config.preset_file + async with aiofiles.open(preset_file, "r", encoding="utf-8") as f: resp = await f.read() files = "" -- 2.49.1