mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
make colab friendly
This commit is contained in:
parent
ad97c5a707
commit
509cf532ce
@ -313,6 +313,7 @@ class Interface:
|
|||||||
is_colab = utils.colab_check()
|
is_colab = utils.colab_check()
|
||||||
if is_colab:
|
if is_colab:
|
||||||
share = True
|
share = True
|
||||||
|
print("->", share)
|
||||||
if not is_colab:
|
if not is_colab:
|
||||||
if not networking.url_ok(path_to_local_server):
|
if not networking.url_ok(path_to_local_server):
|
||||||
share = True
|
share = True
|
||||||
@ -331,8 +332,6 @@ class Interface:
|
|||||||
try:
|
try:
|
||||||
share_url = networking.setup_tunnel(server_port)
|
share_url = networking.setup_tunnel(server_port)
|
||||||
print("Running on External URL:", share_url)
|
print("Running on External URL:", share_url)
|
||||||
if is_colab and self.verbose:
|
|
||||||
print(strings.en["COLAB_NO_LOCAL"])
|
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
data = {'error': 'RuntimeError in launch method'}
|
data = {'error': 'RuntimeError in launch method'}
|
||||||
if self.analytics_enabled:
|
if self.analytics_enabled:
|
||||||
@ -372,8 +371,10 @@ class Interface:
|
|||||||
if share:
|
if share:
|
||||||
while not networking.url_ok(share_url):
|
while not networking.url_ok(share_url):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
print("a ->")
|
||||||
display(IFrame(share_url, width=1000, height=500))
|
display(IFrame(share_url, width=1000, height=500))
|
||||||
else:
|
else:
|
||||||
|
print("b ->")
|
||||||
display(IFrame(path_to_local_server, width=1000, height=500))
|
display(IFrame(path_to_local_server, width=1000, height=500))
|
||||||
|
|
||||||
r = requests.get(path_to_local_server + "enable_sharing/" + (share_url or "None"))
|
r = requests.get(path_to_local_server + "enable_sharing/" + (share_url or "None"))
|
||||||
|
Loading…
Reference in New Issue
Block a user