🐛 fix(__main__.py): add support for running Langflow on Windows

 feat(__main__.py): add support for running Langflow on MacOS and Linux using gunicorn
The changes add support for running Langflow on Windows by using uvicorn instead of gunicorn. This is because Windows doesn't support gunicorn. The changes also add support for running Langflow on MacOS and Linux using gunicorn. This is because MacOS requires an env variable to be set to use gunicorn.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-19 09:55:29 -03:00
commit e01993b7f1

View file

@ -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.