Skip to content

Commit 1ba5a57

Browse files
authored
Merge pull request #128 from Zsailer/extension-browser-open
[MRG] add open_browser trait to ExtensionApp
2 parents ffb0744 + e0fdaf4 commit 1ba5a57

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

jupyter_server/extension/application.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from traitlets import (
55
Unicode,
66
List,
7-
Dict,
7+
Dict,
8+
Bool,
89
default,
910
validate
1011
)
@@ -80,6 +81,12 @@ def _preparse_for_stopping_flags(Application, argv):
8081
app.exit(0)
8182

8283

84+
flags['no-browser']=(
85+
{'ExtensionApp' : {'open_browser' : True}},
86+
_("Prevent the opening of the default url in the browser.")
87+
)
88+
89+
8390
class ExtensionApp(JupyterApp):
8491
"""Base class for configurable Jupyter Server Extension Applications.
8592
@@ -176,6 +183,11 @@ def _config_file_name_default(self):
176183
help=_("The default URL to redirect to from `/`")
177184
)
178185

186+
open_browser = Bool(
187+
True,
188+
help=_("Should the extension open a browser window?")
189+
)
190+
179191
custom_display_url = Unicode(u'', config=True,
180192
help=_("""Override URL shown to users.
181193
@@ -335,7 +347,7 @@ def start(self):
335347
# Override the server's display url to show extension's display URL.
336348
self.serverapp.custom_display_url = self.custom_display_url
337349
# Override the server's default option and open a broswer window.
338-
self.serverapp.open_browser = True
350+
self.serverapp.open_browser = self.open_browser
339351
# Hijack the server's browser-open file to land on
340352
# the extensions home page.
341353
self.serverapp._write_browser_open_file = self._write_browser_open_file

0 commit comments

Comments
 (0)