import threading import time from src.main import app def run_app(): app.run(host="127.0.0.1", port=5000, debug=False, use_reloader=False) def start_flask_in_thread(): thread = threading.Thread(target=run_app) thread.daemon = True thread.start() # Wait a bit for the server to start time.sleep(2) return thread