aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.py
diff options
context:
space:
mode:
authorkj_sh6042026-06-01 13:34:03 -0400
committerkj_sh6042026-06-01 13:34:03 -0400
commit97942ca6f1a38c133c5e1adb7b5ea10d84c81985 (patch)
treedc9dc314ced42d9a1891a6b356b3235c6a489f9a /src/app.py
parent6aea2bf6305e6d266f7ec7d54bd1966b050e7f79 (diff)
refactor: move nyan.png to original locationHEADmain
Diffstat (limited to 'src/app.py')
-rw-r--r--src/app.py7
1 files changed, 5 insertions, 2 deletions
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/<filename>")
@@ -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)