From 5ec79945dfaa539a16b68a3bf237cb9ef4be80bd Mon Sep 17 00:00:00 2001 From: Radiquum Date: Sun, 4 May 2025 05:57:29 +0500 Subject: [PATCH] fix: dev script --- dev.py | 9 +++++---- src/main.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/dev.py b/dev.py index 1aa7692..5115acf 100644 --- a/dev.py +++ b/dev.py @@ -5,15 +5,16 @@ import os if __name__ == "__main__": environment = os.environ.copy() + environment["is_dev"] = "True" - gui_proc = subprocess.Popen(["bun", "run", "dev"], cwd="./gui", shell = True) - app_proc = subprocess.Popen(["python", "main.py"], cwd="./src", 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 is None: + while gui_proc.poll() is None or app_proc.poll() is None: time.sleep(0.1) except KeyboardInterrupt: gui_proc.terminate() app_proc.terminate() - print("Processed Terminated") \ No newline at end of file + print("Processes Terminated") \ No newline at end of file diff --git a/src/main.py b/src/main.py index 5d5b068..0ff02f1 100644 --- a/src/main.py +++ b/src/main.py @@ -6,11 +6,13 @@ import os app = Flask(__name__) +# TODO: auto copy next html files to templates folder @app.route("/") def index(): return render_template("index.html") +# TODO: auto copy next static out on build to static folder @app.route("/") def rewrite_next(path): if os.path.exists(f"./static/{path}"): @@ -24,7 +26,9 @@ def page_not_found(e): if __name__ == "__main__": - # If you are debugging you can do that in the browser: - app.run(host="0.0.0.0", debug=True, use_reloader=True) - # If you want to view the flaskwebgui window: -# FlaskUI(app=app, server="flask").run() + + # TODO: if env == dev then Flask if prod then FlaskUI + if os.getenv("is_dev") == "True": + app.run(host="0.0.0.0", debug=True, use_reloader=True) + else: + FlaskUI(app=app, server="flask").run()