File: application.py

package info (click to toggle)
jupyter-server 1.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,844 kB
  • sloc: python: 12,331; makefile: 175; javascript: 72
file content (50 lines) | stat: -rw-r--r-- 1,626 bytes parent folder | download
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
import os, jinja2
from traitlets import Unicode
from jupyter_server.extension.application import ExtensionApp, ExtensionAppJinjaMixin
from .handlers import ParameterHandler, TemplateHandler, IndexHandler, ErrorHandler

DEFAULT_STATIC_FILES_PATH = os.path.join(os.path.dirname(__file__), "static")
DEFAULT_TEMPLATE_FILES_PATH = os.path.join(os.path.dirname(__file__), "templates")

class SimpleApp2(ExtensionAppJinjaMixin, ExtensionApp):

    # The name of the extension.
    name = "simple_ext2"

    # Te url that your extension will serve its homepage.
    extension_url = '/simple_ext2'

    # Should your extension expose other server extensions when launched directly?
    load_other_extensions = True

    # Local path to static files directory.
    static_paths = [
        DEFAULT_STATIC_FILES_PATH
    ]

    # Local path to templates directory.
    template_paths = [
        DEFAULT_TEMPLATE_FILES_PATH
    ]

    configD = Unicode('',
        config=True,
        help='Config D example.'
    )

    def initialize_handlers(self):
        self.handlers.extend([
            (r'/simple_ext2/params/(.+)$', ParameterHandler),
            (r'/simple_ext2/template', TemplateHandler),
            (r'/simple_ext2/?', IndexHandler),
            (r'/simple_ext2/(.*)', ErrorHandler)
        ])

    def initialize_settings(self):
        self.log.info('Config {}'.format(self.config))

#-----------------------------------------------------------------------------
# Main entry point
#-----------------------------------------------------------------------------

main = launch_new_instance = SimpleApp2.launch_instance