From e5d84d933758109eaf0b44faa65eb01500faecfe Mon Sep 17 00:00:00 2001 From: spitkov Date: Sun, 8 Sep 2024 14:03:18 +0200 Subject: [PATCH] Update app.py raw part 2 --- app.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app.py b/app.py index f9f7419..fd25782 100644 --- a/app.py +++ b/app.py @@ -119,6 +119,19 @@ def redirect_vanity(vanity): 'size': os.path.getsize(file_path), 'modified_at': datetime.fromtimestamp(os.path.getmtime(file_path)).strftime('%Y-%m-%d %H:%M:%S'), 'url': url_for('download_file', vanity=vanity) +@app.route('//raw', methods=['GET']) +ef redirect_vanity(vanity): + target = data_store.get(vanity) + if target: + if target['type'] == 'pastebin': + return render_template(f'{vanity}raw.html') + elif target['type'] == 'file': + file_path = os.path.join(app.config['UPLOAD_FOLDER'], f'{vanity}_{target["filename"]}') + file_info = { + 'name': target['filename'], + 'size': os.path.getsize(file_path), + 'modified_at': datetime.fromtimestamp(os.path.getmtime(file_path)).strftime('%Y-%m-%d %H:%M:%S'), + 'url': url_for('download_file', vanity=vanity) } return render_template(f'{vanity}.html', **file_info) elif target['type'] == 'url':