allow configurable port

This commit is contained in:
Abubakar Abid 2020-07-18 12:50:03 -05:00
parent 38639079bf
commit fe3171a934
2 changed files with 5 additions and 3 deletions

View File

@ -40,7 +40,7 @@ class Interface:
def __init__(self, fn, inputs, outputs, saliency=None, verbose=False, examples=None,
live=False, show_input=True, show_output=True,
capture_session=False, title=None, description=None,
thumbnail=None, server_name=networking.LOCALHOST_NAME):
thumbnail=None, server_port=None, server_name=networking.LOCALHOST_NAME):
"""
Parameters:
fn (Callable): the function to wrap an interface around.
@ -97,7 +97,7 @@ class Interface:
self.description = description
self.thumbnail = thumbnail
self.examples = examples
self.server_port = None
self.server_port = server_port
self.simple_server = None
Interface.instances.add(self)

View File

@ -231,7 +231,9 @@ def serve_files_in_background(interface, port, directory_to_serve=None, server_n
return httpd
def start_simple_server(interface, directory_to_serve=None, server_name=None, server_port=INITIAL_PORT_VALUE):
def start_simple_server(interface, directory_to_serve=None, server_name=None, server_port=None):
if server_port is None:
server_port = INITIAL_PORT_VALUE
port = get_first_available_port(
server_port, server_port + TRY_NUM_PORTS
)