From 104b87d5559c85097bdddcb269abe6b1a58eb0e8 Mon Sep 17 00:00:00 2001 From: csd4ni3l Date: Sat, 9 Aug 2025 11:39:11 +0200 Subject: [PATCH] fix png not working because of removing too many bytes of data url header --- main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 5e5b546..2d06fd2 100644 --- a/main.py +++ b/main.py @@ -17,8 +17,6 @@ login_manager.init_app(app) os.makedirs("uploads", exist_ok=True) -users = {} - class User(flask_login.UserMixin): pass @@ -57,9 +55,12 @@ def resize_image_file(path, max_side=256, fmt="JPEG"): @app.route("/upload", methods=["POST"]) def upload(): try: - image_type, image_data = request.json["image_type"], request.json["image_data"].encode("utf-8") + image_type, image_data = request.json["username"], request.json["image_type"], request.json["image_data"].encode("utf-8") - image_data = image_data[23:] # data:image/jpeg;base64, + if image_type == "jpeg": + image_data = image_data[23:] # data:image/jpeg;base64, + else: + image_data = image_data[22:] image_uuid = uuid.uuid4()