@@ -30,6 +30,7 @@ def _parse_args():
3030 is provided, it will be set to 0 by default." ,
3131 )
3232 args .add_argument ("--port" , type = int , default = 7860 , help = "The port number to run gradio." )
33+ args .add_argument ("--host" , type = str , default = "127.0.0.1" , help = "The local host to run gradio." )
3334 args .add_argument (
3435 "--share" ,
3536 action = "store_true" ,
@@ -147,8 +148,7 @@ def gradio_stats(self):
147148
148149
149150def launch_gradio (
150- artifact_path : str = "dist" , device : str = "auto" , port : int = 7860 , share : bool = False
151- ):
151+ artifact_path : str = "dist" , device : str = "auto" , port : int = 7860 , share : bool = False , host : str = "127.0.0.1" ):
152152 r"""Launch the gradio interface with a given port, creating a publically sharable link if specified."""
153153
154154 # create a gradio module
@@ -230,9 +230,9 @@ def launch_gradio(
230230 stats_button .click (mod .gradio_stats , [], [stats_output ])
231231
232232 # launch to the web
233- demo .launch (share = share , enable_queue = True , server_port = port )
233+ demo .launch (share = share , enable_queue = True , server_port = port , server_name = host )
234234
235235
236236if __name__ == "__main__" :
237237 ARGS = _parse_args ()
238- launch_gradio (ARGS .artifact_path , ARGS .device , ARGS .port , ARGS .share )
238+ launch_gradio (ARGS .artifact_path , ARGS .device , ARGS .port , ARGS .share , ARGS . host )
0 commit comments