From 97942ca6f1a38c133c5e1adb7b5ea10d84c81985 Mon Sep 17 00:00:00 2001 From: kj_sh604 Date: Mon, 1 Jun 2026 13:34:03 -0400 Subject: refactor: move nyan.png to original location --- src/app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/app.py') diff --git a/src/app.py b/src/app.py index edd0f59..1ff357e 100644 --- a/src/app.py +++ b/src/app.py @@ -5,6 +5,7 @@ import hashlib import os import re import secrets +import string import subprocess import time from pathlib import Path @@ -215,7 +216,7 @@ def favicon_svg(): @app.route("/nyan.png") def nyan_png(): - return send_from_directory(app.root_path, "nyan.png") + return send_from_directory(UPLOAD_DIR, "nyan.png") @app.route("/uploads/") @@ -244,7 +245,9 @@ def upload(): ext = ALLOWED_MIME[mime] basename = re.sub(r"[^a-zA-Z0-9_-]", "_", Path(f.filename).stem)[:64] or "image" - filename = f"{basename}_{secrets.token_hex(4)}.{ext}" + epoch = int(time.time()) + rand = "".join(secrets.choice(string.ascii_lowercase + string.digits) for _ in range(16)) + filename = f"{basename}_{epoch}-{rand}.{ext}" (UPLOAD_DIR / filename).write_bytes(data) -- cgit v1.2.3