small layout changes, refractoring

This commit is contained in:
2025-03-11 10:54:04 +01:00
parent 8fab59a493
commit f3bdb6d53f
6 changed files with 269 additions and 137 deletions
+24 -2
View File
@@ -6,8 +6,18 @@ import subprocess
import sys
import time
import os
import threading
from pathlib import Path
def stream_output(process, prefix):
"""Stream the output of a process to the console in real-time."""
for line in iter(process.stdout.readline, ''):
if line:
print(f"{prefix}: {line.strip()}")
for line in iter(process.stderr.readline, ''):
if line:
print(f"{prefix} ERROR: {line.strip()}")
def start_backend():
"""Start the backend API server."""
print("Starting backend API server...")
@@ -15,8 +25,14 @@ def start_backend():
[sys.executable, "-m", "uvicorn", "mock_backend.mock_api:app", "--host", "0.0.0.0", "--port", "7999", "--reload"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
text=True,
bufsize=1 # Line buffered
)
# Start a thread to stream the backend output
backend_thread = threading.Thread(target=stream_output, args=(backend_process, "BACKEND"), daemon=True)
backend_thread.start()
# Wait a moment to ensure the backend has started
time.sleep(2)
return backend_process
@@ -28,8 +44,14 @@ def start_frontend():
[sys.executable, "-m", "streamlit", "run", "auracaster-webui.py"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
text=True,
bufsize=1 # Line buffered
)
# Start a thread to stream the frontend output
frontend_thread = threading.Thread(target=stream_output, args=(frontend_process, "FRONTEND"), daemon=True)
frontend_thread.start()
return frontend_process
if __name__ == "__main__":