diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 5598fb78c..29f60ed23 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -152,6 +152,17 @@ def serve( "timeout": timeout, } + if platform.system() in ["Windows"]: + # Run using uvicorn on MacOS and Windows + # Windows doesn't support gunicorn + # MacOS requires an env variable to be set to use gunicorn + run_on_windows(host, port, log_level, options, app) + else: + # Run using gunicorn on Linux + run_on_mac_or_linux(host, port, log_level, options, app, open_browser) + + +def run_on_mac_or_linux(host, port, log_level, options, app, open_browser=True): webapp_process = Process( target=run_langflow, args=(host, port, log_level, options, app) ) @@ -169,6 +180,14 @@ def serve( webbrowser.open(f"http://{host}:{port}") +def run_on_windows(host, port, log_level, options, app): + """ + Run the Langflow server on Windows. + """ + print_banner(host, port) + run_langflow(host, port, log_level, options, app) + + def setup_static_files(app: FastAPI, static_files_dir: Path): """ Setup the static files directory.