Skip to content

Commit

Permalink
Merge pull request #57 from logspace-ai/dev
Browse files Browse the repository at this point in the history
Release 0.0.45
  • Loading branch information
ibiscp authored Mar 20, 2023
2 parents 15a5e99 + d8c1eac commit b250f76
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langflow"
version = "0.0.44"
version = "0.0.45"
description = "A Python package with a built-in web application"
authors = ["Logspace <contact@logspace.ai>"]
packages = [
Expand Down
39 changes: 0 additions & 39 deletions src/backend/langflow/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,6 @@ def get_number_of_workers(workers=None):
return workers


def replace_port(static_files_dir, host, port):
# Load index.html from frontend directory
# In it there is a script tag that sets the base url
# like so setItem("port", "http://localhost:7860")
# localhost could be anything so we need to verify for string
# we need to set the base url to the port that the server is running on
# so that the frontend can make requests to the backend
# This is a hacky way to do it, but it works

# Check if the host is http or https
logger.info(f"host: {host}")
logger.info(f"port: {port}")
url = f"{host}:{port}" if "http" in host else f"http://{host}:{port}"
logger.info(f"url: {url}")
new_string = f'setItem("port","{url}")'

with open(static_files_dir / "index.html", "r") as f:
index_html = f.read()
# using regex to replace the port
index_html = re.sub(
r"setItem\(\"port\",.*\)",
new_string,
index_html,
)
with open(static_files_dir / "index.html", "w") as f:
f.write(index_html)
# Verify that the port was replaced
with open(static_files_dir / "index.html", "r") as f:
index_html = f.read()
if new_string not in index_html:
raise ValueError(
"The port was not replaced in index.html. "
"Please check the regex in main.py"
)


def serve(
host: str = "127.0.0.1", workers: int = 1, timeout: int = 60, port: int = 7860
):
Expand All @@ -73,9 +37,6 @@ def serve(
"timeout": timeout,
}

# Replace the port in index.html
replace_port(static_files_dir, host, port)

if platform.system() in ["Darwin", "Windows"]:
# Run using uvicorn on MacOS and Windows
# Windows doesn't support gunicorn
Expand Down

0 comments on commit b250f76

Please sign in to comment.