fix: dev script

This commit is contained in:
Kentai Radiquum 2025-05-04 05:57:29 +05:00
parent 90d8422b81
commit 5ec79945df
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
2 changed files with 13 additions and 8 deletions

9
dev.py
View file

@ -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")
print("Processes Terminated")

View file

@ -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("/<path:path>")
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()