mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
Pass to networking module to make app accessible on LAN.
This commit is contained in:
parent
83b986c7a0
commit
896240d324
@ -61,6 +61,7 @@ class Interface:
|
|||||||
title (str): a title for the interface; if provided, appears above the input and output components.
|
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.
|
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
|
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_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.
|
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.
|
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)
|
networking.set_meta_tags(self.title, self.description, self.thumbnail)
|
||||||
|
|
||||||
server_port, app, thread = networking.start_server(
|
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)
|
path_to_local_server = "http://{}:{}/".format(self.server_name, server_port)
|
||||||
self.server_port = server_port
|
self.server_port = server_port
|
||||||
self.status = "RUNNING"
|
self.status = "RUNNING"
|
||||||
|
@ -163,7 +163,7 @@ def interpret():
|
|||||||
def file(path):
|
def file(path):
|
||||||
return send_file(os.path.join(app.cwd, 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:
|
if server_port is None:
|
||||||
server_port = INITIAL_PORT_VALUE
|
server_port = INITIAL_PORT_VALUE
|
||||||
port = get_first_available_port(
|
port = get_first_available_port(
|
||||||
@ -173,7 +173,7 @@ def start_server(interface, server_port=None):
|
|||||||
app.cwd = os.getcwd()
|
app.cwd = os.getcwd()
|
||||||
log = logging.getLogger('werkzeug')
|
log = logging.getLogger('werkzeug')
|
||||||
log.setLevel(logging.ERROR)
|
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()
|
process.start()
|
||||||
return port, app, process
|
return port, app, process
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user