From c74170a14d982b79081377583909e7eceb29ef3c Mon Sep 17 00:00:00 2001 From: Radiquum Date: Mon, 5 May 2025 03:19:56 +0500 Subject: [PATCH] format --- build.py | 7 +++++-- dev.py | 10 +++++++--- src/api/__init__.py | 4 ++-- src/api/pack.py | 5 ++++- src/config.py | 1 + src/main.py | 1 + 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/build.py b/build.py index c585769..1813132 100644 --- a/build.py +++ b/build.py @@ -13,7 +13,10 @@ parser = argparse.ArgumentParser( epilog="", ) parser.add_argument( - "--no-rebuild", help="don't rebuild Next.js frontend", action="store_true", default=False + "--no-rebuild", + help="don't rebuild Next.js frontend", + action="store_true", + default=False, ) parser.add_argument( "--exe", help="create an executable file", action="store_true", default=False @@ -107,4 +110,4 @@ if __name__ == "__main__": if os.path.exists(f"{OUT_DIR}/__pycache__") and os.path.isdir( f"{OUT_DIR}/__pycache__" ): - shutil.rmtree(f"{OUT_DIR}/__pycache__") \ No newline at end of file + shutil.rmtree(f"{OUT_DIR}/__pycache__") diff --git a/dev.py b/dev.py index 380b15f..41ada51 100644 --- a/dev.py +++ b/dev.py @@ -11,8 +11,12 @@ if __name__ == "__main__": # TODO: handle multiple package managers line npm(node), deno, yarn # TODO?: install node deps automatically - gui_proc = subprocess.Popen(["bun", "run", "dev"], cwd="./gui", env=environment, shell = True) - app_proc = subprocess.Popen(["python", "main.py"], cwd="./src", env=environment, shell = True) + gui_proc = subprocess.Popen( + ["bun", "run", "dev"], cwd="./gui", env=environment, shell=True + ) + app_proc = subprocess.Popen( + ["python", "main.py"], cwd="./src", env=environment, shell=True + ) try: while gui_proc.poll() is None or app_proc.poll() is None: @@ -21,4 +25,4 @@ if __name__ == "__main__": except KeyboardInterrupt: gui_proc.terminate() app_proc.terminate() - print("Processes Terminated") \ No newline at end of file + print("Processes Terminated") diff --git a/src/api/__init__.py b/src/api/__init__.py index aeacd09..09ebb9d 100644 --- a/src/api/__init__.py +++ b/src/api/__init__.py @@ -1,5 +1,5 @@ from flask import Blueprint -api = Blueprint('api', __name__, url_prefix="/api/pack") +api = Blueprint("api", __name__, url_prefix="/api/pack") -from . import pack \ No newline at end of file +from . import pack diff --git a/src/api/pack.py b/src/api/pack.py index 4d48eb5..b2836fc 100644 --- a/src/api/pack.py +++ b/src/api/pack.py @@ -8,6 +8,7 @@ from PIL import Image from io import BytesIO import base64 + @api.route("/new", methods=["POST"]) def APIPackNew(): pack = { @@ -54,7 +55,9 @@ def APIPackImageEdit(id): if image_mime == None or image_mime not in IMG_ALLOWED_MIME: return jsonify({"status": "error", "message": "wrong image format"}) - image_data = base64.b64decode(re.sub("^data:image/.+;base64,", "", request.json.get("image"))) + image_data = base64.b64decode( + re.sub("^data:image/.+;base64,", "", request.json.get("image")) + ) image = Image.open(BytesIO(image_data)) image = image.resize((512, 512), Image.Resampling.LANCZOS) diff --git a/src/config.py b/src/config.py index 43c3e62..acbc419 100644 --- a/src/config.py +++ b/src/config.py @@ -1,4 +1,5 @@ import os + PACKS_FOLDER = "./packs" if os.getenv("is_dev") == "True": PACKS_FOLDER = "../packs" diff --git a/src/main.py b/src/main.py index a5c42d2..032d101 100644 --- a/src/main.py +++ b/src/main.py @@ -24,6 +24,7 @@ app = Flask( app.register_blueprint(api) if os.getenv("is_dev") == "True": from flask_cors import CORS + CORS(app, resources={r"/*": {"origins": "*"}})