add LAN support

This commit is contained in:
luanjintai 2023-03-25 15:59:57 +08:00
parent 13d82d3593
commit 959ab91484

View File

@ -1099,6 +1099,8 @@ def UI(**kwargs):
launch_kwargs['server_port'] = kwargs.get('server_port', 0)
if kwargs.get('inbrowser', False):
launch_kwargs['inbrowser'] = kwargs.get('inbrowser', False)
if kwargs.get('listen', True):
launch_kwargs['server_name'] = "0.0.0.0"
print(launch_kwargs)
interface.launch(**launch_kwargs)
@ -1121,6 +1123,9 @@ if __name__ == '__main__':
parser.add_argument(
'--inbrowser', action='store_true', help='Open in browser'
)
parser.add_argument(
'--listen', action='store_true', help='Launch gradio with server name 0.0.0.0, allowing LAN access'
)
args = parser.parse_args()