made server port configurable

This commit is contained in:
Abubakar Abid 2020-07-18 12:32:30 -05:00
parent b37254442b
commit 018c43a4e2
2 changed files with 4 additions and 3 deletions

View File

@ -268,7 +268,8 @@ class Interface:
output_directory = tempfile.mkdtemp() output_directory = tempfile.mkdtemp()
# Set up a port to serve the directory containing the static files with interface. # Set up a port to serve the directory containing the static files with interface.
server_port, httpd = networking.start_simple_server(self, output_directory, self.server_name) server_port, httpd = networking.start_simple_server(self, output_directory, self.server_name,
server_port=self.server_port)
path_to_local_server = "http://{}:{}/".format(self.server_name, server_port) path_to_local_server = "http://{}:{}/".format(self.server_name, server_port)
networking.build_template(output_directory) networking.build_template(output_directory)

View File

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