Skip to content

Commit

Permalink
馃悰 use a new port if the default is in use
Browse files Browse the repository at this point in the history
closes #11
  • Loading branch information
ehne committed Sep 28, 2021
1 parent 482bd16 commit 662b294
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pynode_next/core.py
Expand Up @@ -5,15 +5,20 @@

class Core:
def __init__(self, port=5050):
self.port = 5050
self.port = port
base_path = os.path.relpath(__file__)
self.custom_ui = f"{Path(base_path).parent}/ui.html"
self.callback = None


def run(self, func):
"""A function that runs a different function in the PyNode Next web environment."""
self.server = algx.http_server(port=self.port, file=self.custom_ui)
while 1:
try:
self.server = algx.http_server(port=self.port, file=self.custom_ui)
break
except:
self.port += 1
print("serving ui found at", self.custom_ui)

self.canvas = self.server.canvas()
Expand Down
1 change: 0 additions & 1 deletion test.py
Expand Up @@ -7,7 +7,6 @@


def test():
raise Error('hello')
graph.add_node("a")
graph.add_node("b")
pause(500)
Expand Down

0 comments on commit 662b294

Please sign in to comment.