diff --git a/gradio/interface.py b/gradio/interface.py index d8ed3ae0c3..36482b93e1 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -268,7 +268,8 @@ class Interface: output_directory = tempfile.mkdtemp() # 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) networking.build_template(output_directory) diff --git a/gradio/networking.py b/gradio/networking.py index 6eaf8c25b7..7c83e10c2a 100644 --- a/gradio/networking.py +++ b/gradio/networking.py @@ -222,9 +222,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): +def start_simple_server(interface, directory_to_serve=None, server_name=None, server_port=INITIAL_PORT_VALUE): 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) return port, httpd