Skip to content

Commit

Permalink
chore: show the server
Browse files Browse the repository at this point in the history
  • Loading branch information
islxyqwe committed Dec 2, 2024
1 parent 5e2c1b3 commit 4b44a4d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pygwalker/api/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
from pygwalker.utils import fallback_value
from pygwalker.utils.encode import DataFrameEncoder

def get_server_url(port: int) -> str:
"""Generate server URLs for both localhost and network access."""
localhost_url = f"http://localhost:{port}"

# Get machine's IP address for network access
import socket
hostname = socket.gethostname()
ip_address = socket.gethostbyname(hostname)
network_url = f"http://{ip_address}:{port}"

return f"""Server running at:
- Local: {localhost_url}
- Network: {network_url}"""

def start_server(walker: PygWalker):
comm = BaseCommunication(walker.gid)
walker._init_callback(comm)
Expand All @@ -37,6 +51,7 @@ def pyg_html():

port = 3000
while True:
print("\n" + get_server_url(port))
try:
run(app, host='0.0.0.0', port=port)
break
Expand Down

0 comments on commit 4b44a4d

Please sign in to comment.