From 8bad36271a3ef68b2e93b32e541317895c8d1a8d Mon Sep 17 00:00:00 2001 From: Kenny Cheng Date: Sat, 26 Oct 2024 01:18:01 +0800 Subject: [PATCH] not mixing dump file with cached file --- app.py | 23 ++++++++++++----------- templates/dump.html | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index 2025bdf..d4cffe1 100644 --- a/app.py +++ b/app.py @@ -60,16 +60,6 @@ def create_cache(): if is_image_valid(image_path): cached_images.append(image) - - for image in os.listdir(app.config['DUMP_FOLDER']): - image_path = os.path.join(app.config['DUMP_FOLDER'], image) - cache_path = os.path.join(app.config['CACHE_FOLDER'], image) - - if not os.path.exists(cache_path) and is_image_valid(image_path): - resize_image(image_path, cache_path) - - if is_image_valid(image_path): - cached_images.append(image) return cached_images @@ -149,6 +139,17 @@ def cached_file(filename): else: return "Invalid image", 404 +@app.route('/dump/') +def dump_file(filename): + if not session.get('logged_in'): + return redirect(url_for('login')) + + image_path = os.path.join(app.config['DUMP_FOLDER'], filename) + if is_image_valid(image_path): + return send_from_directory(app.config['DUMP_FOLDER'], filename) + else: + return "Invalid image", 404 + @app.route('/api/images') def api_images(): if not session.get('logged_in'): @@ -167,7 +168,7 @@ def dump(): if not session.get('logged_in'): return redirect(url_for('login')) - cached_images = create_cache() + #cached_images = create_cache() dump_folder = app.config['DUMP_FOLDER'] # Folder to store dump images images = sorted( os.listdir(dump_folder), diff --git a/templates/dump.html b/templates/dump.html index ba30462..28868fd 100644 --- a/templates/dump.html +++ b/templates/dump.html @@ -13,8 +13,8 @@

Pumpkin Gallery🎃