Skip to content

Commit e9d1a69

Browse files
committed
extension 11 has flags and aliases
1 parent ea0555a commit e9d1a69

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

examples/simple/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,18 @@ Try with the above links to check that only Extension 2 is responding (Extension
9999

100100
## Extension 11 extending Extension 1
101101

102+
`Extension 11` extends `Extension 1`. It also implemnets additional flags and aliases.
103+
104+
The `--hello` flag will log on startup `Hello Simple11 - You have provided the --hello flag or defined a c.SimpleApp1.hello == True`.
105+
102106
```bash
103-
jupyter simple-ext11
107+
jupyter simple-ext11 --hello
104108
# or...
105-
jupyter server --ServerApp.jpserver_extensions="{'simple_ext11': True}"
109+
jupyter server --ServerApp.jpserver_extensions="{'simple_ext11': True}" --hello
106110
```
107111

112+
Ensure the following URLs give respond correctly.
113+
108114
```bash
109115
# Jupyter Server Home Page.
110116
open http://localhost:8888/

examples/simple/simple_ext11/application.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import os
22
from simple_ext1.application import SimpleApp1
3+
from jupyter_server.serverapp import aliases, flags
34

45
DEFAULT_STATIC_FILES_PATH = os.path.join(os.path.dirname(__file__), "./../simple_ext1/static")
56
DEFAULT_TEMPLATE_FILES_PATH = os.path.join(os.path.dirname(__file__), "./../simple_ext1/templates")
67

78
class SimpleApp11(SimpleApp1):
9+
flags['hello']=(
10+
{'SimpleApp11' : {'hello' : True}},
11+
"Say hello on startup."
12+
)
13+
aliases.update({
14+
'notebook-dir': 'ServerApp.notebook_dir',
15+
})
816

917
# The name of the extension.
1018
extension_name = "simple_ext11"
@@ -19,14 +27,16 @@ class SimpleApp11(SimpleApp1):
1927
DEFAULT_TEMPLATE_FILES_PATH
2028
]
2129

22-
def initialize_handlers(self):
23-
super().initialize_handlers()
24-
25-
def initialize_templates(self):
26-
super().initialize_templates()
30+
def get_conf(self, key):
31+
simple_app_11 = self.settings.get('config').get('SimpleApp11')
32+
if simple_app_11:
33+
return simple_app_11.get(key, None)
34+
return None
2735

2836
def initialize_settings(self):
29-
super().initialize_templates()
37+
if self.get_conf('hello') == True:
38+
self.log.info('Hello Simple11 - You have provided the --hello flag or defined a c.SimpleApp1.hello == True')
39+
super().initialize_settings()
3040

3141
#-----------------------------------------------------------------------------
3242
# Main entry point

0 commit comments

Comments
 (0)