diff --git a/gradio/interface.py b/gradio/interface.py index 3b4d5507bc..094445734d 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -61,6 +61,7 @@ class Interface: title (str): a title for the interface; if provided, appears above the input and output components. description (str): a description for the interface; if provided, appears above the input and output components. thumbnail (str): path to image or src to use as display picture for models listed in gradio.app/hub + server_name (str): to make app accessible on local network set to "0.0.0.0". allow_screenshot (bool): if False, users will not see a button to take a screenshot of the interface. allow_flagging (bool): if False, users will not see a button to flag an input and output. flagging_dir (str): what to name the dir where flagged data is stored. @@ -337,7 +338,7 @@ class Interface: networking.set_meta_tags(self.title, self.description, self.thumbnail) server_port, app, thread = networking.start_server( - self, self.server_port) + self, self.server_name, self.server_port) path_to_local_server = "http://{}:{}/".format(self.server_name, server_port) self.server_port = server_port self.status = "RUNNING" diff --git a/gradio/networking.py b/gradio/networking.py index ee32b50dd5..2c69fb267c 100644 --- a/gradio/networking.py +++ b/gradio/networking.py @@ -163,7 +163,7 @@ def interpret(): def file(path): return send_file(os.path.join(app.cwd, path)) -def start_server(interface, server_port=None): +def start_server(interface, server_name, server_port=None): if server_port is None: server_port = INITIAL_PORT_VALUE port = get_first_available_port( @@ -173,7 +173,7 @@ def start_server(interface, server_port=None): app.cwd = os.getcwd() log = logging.getLogger('werkzeug') log.setLevel(logging.ERROR) - process = threading.Thread(target=app.run, kwargs={"port": port}) + process = threading.Thread(target=app.run, kwargs={"port": port, "host": server_name}) process.start() return port, app, process