From 99e373771890474310a6cfb39cb29861c733053b Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Tue, 16 Jul 2024 17:19:39 +0200 Subject: [PATCH] =?UTF-8?q?Startar=20upp=20allla=20tj=C3=A4nster?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smartassist/src/startservices.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 smartassist/src/startservices.py diff --git a/smartassist/src/startservices.py b/smartassist/src/startservices.py new file mode 100644 index 0000000..76e94c0 --- /dev/null +++ b/smartassist/src/startservices.py @@ -0,0 +1,23 @@ +# Start all services +import subprocess +import threading + +from backend import run_flask + +def start_frontend(): + try: + # Start frontend (web server) as a separate process + subprocess.Popen(["python", "-m", "http.server", "8000"]) + except Exception as e: + print(f"Failed to start frontend: {e}") + +def start_backend(): + try: + # Start backend as a separate thread + threading.Thread(target=run_flask).start() + except Exception as e: + print(f"Failed to start backend: {e}") + +if __name__ == '__main__': + start_backend() + start_frontend()