forked from jupyter-server/jupyter_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
72 lines (53 loc) · 2.1 KB
/
application.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
from simple_ext1.application import SimpleApp1
from traitlets import Bool, Unicode, observe
from jupyter_server.serverapp import aliases, flags
DEFAULT_STATIC_FILES_PATH = os.path.join(os.path.dirname(__file__), "./../simple_ext1/static")
DEFAULT_TEMPLATE_FILES_PATH = os.path.join(os.path.dirname(__file__), "./../simple_ext1/templates")
class SimpleApp11(SimpleApp1):
flags["hello"] = ({"SimpleApp11": {"hello": True}}, "Say hello on startup.")
aliases.update(
{
"simple11-dir": "SimpleApp11.simple11_dir",
}
)
# The name of the extension.
name = "simple_ext11"
# Te url that your extension will serve its homepage.
extension_url = "/simple_ext11/default"
# Local path to static files directory.
static_paths = [DEFAULT_STATIC_FILES_PATH]
# Local path to templates directory.
template_paths = [DEFAULT_TEMPLATE_FILES_PATH]
simple11_dir = Unicode("", config=True, help="Simple directory")
hello = Bool(
False,
config=True,
help="Say hello",
)
ignore_js = Bool(
False,
config=True,
help="Ignore Javascript",
)
@observe("ignore_js")
def _update_ignore_js(self, change):
"""TODO Does the observe work?"""
self.log.info("ignore_js has just changed: {}".format(change))
@property
def simple11_dir_formatted(self):
return "/" + self.simple11_dir
def initialize_settings(self):
self.log.info("hello: {}".format(self.hello))
if self.hello is True:
self.log.info(
"Hello Simple11: You have launched with --hello flag or defined 'c.SimpleApp1.hello == True' in your config file"
)
self.log.info("ignore_js: {}".format(self.ignore_js))
super().initialize_settings()
def initialize_handlers(self):
super().initialize_handlers()
# -----------------------------------------------------------------------------
# Main entry point
# -----------------------------------------------------------------------------
main = launch_new_instance = SimpleApp11.launch_instance