88
99
1010from IPython .display import IFrame , display
11- from .comms import _dash_comm , _jupyter_config , _request_jupyter_proxy_config
11+ from .comms import _dash_comm , _jupyter_config , _request_jupyter_config
1212
1313
1414class JupyterDash (dash .Dash ):
1515 @classmethod
16- def infer_jupyter_proxy_config (cls ):
17- try :
18- import jupyter_server_proxy
19- except Exception :
20- raise ImportError (
21- "The infer_jupyter_proxy_config function requires the "
22- "jupyter_server_proxy Python package"
23- )
24- _request_jupyter_proxy_config ()
16+ def infer_jupyter_config (cls ):
17+ _request_jupyter_config ()
2518
2619 def __init__ (self , server_url = None , ** kwargs ):
2720
@@ -30,12 +23,19 @@ def __init__(self, server_url=None, **kwargs):
3023 self .default_requests_pathname_prefix = None
3124 self .default_mode = 'external'
3225
33- if 'base_subpath' in _jupyter_config :
26+ # See if jupyter_server_proxy is installed
27+ try :
28+ import jupyter_server_proxy
29+ self ._server_proxy = True
30+ except Exception :
31+ self ._server_proxy = False
32+
33+ if 'base_subpath' in _jupyter_config and self ._server_proxy :
3434 self .default_requests_pathname_prefix = (
3535 _jupyter_config ['base_subpath' ].rstrip ('/' ) + '/proxy/{port}/'
3636 )
3737
38- if 'server_url' in _jupyter_config :
38+ if 'server_url' in _jupyter_config and self . _server_proxy :
3939 self .default_server_url = _jupyter_config ['server_url' ]
4040
4141 if 'frontend' in _jupyter_config :
@@ -206,7 +206,8 @@ def wait_for_app():
206206 # Update front-end extension
207207 _dash_comm .send ({
208208 'type' : 'show' ,
209- 'port' : port
209+ 'port' : port ,
210+ 'url' : dashboard_url ,
210211 })
211212
212213 @classmethod
0 commit comments