mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
made server port configurable
This commit is contained in:
parent
b37254442b
commit
018c43a4e2
@ -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)
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user