Exemple #1
0
    def _create_app(self):
        """Create our tornado web app.

        Returns
        -------
        tornado.web.Application

        """
        routes = [
            (r'/stream', _BrowserWebSocketHandler, dict(server=self)),
            (r'/healthz', HealthHandler, dict(
                health_check=lambda: self.is_ready_for_browser_connection)),
            (r'/debugz', DebugHandler, dict(server=self)),
            (r'/metrics', MetricsHandler),
        ]

        if (config.get_option('global.developmentMode') and
                config.get_option('global.useNode')):
            LOGGER.debug('Serving static content from the Node dev server')
        else:
            static_path = util.get_static_dir()
            LOGGER.debug('Serving static content from %s', static_path)

            routes.extend([
                (r"/()$", StaticFileHandler,
                    {'path': '%s/index.html' % static_path}),
                (r"/(.*)", StaticFileHandler,
                    {'path': '%s/' % static_path}),
            ])

        return tornado.web.Application(routes, **TORNADO_SETTINGS)
Exemple #2
0
    def _create_app(self):
        """Create our tornado web app.

        Returns
        -------
        tornado.web.Application

        """
        base = config.get_option("server.baseUrlPath")
        routes = [
            (
                make_url_path_regex(base, "stream"),
                _BrowserWebSocketHandler,
                dict(server=self),
            ),
            (
                make_url_path_regex(base, "healthz"),
                HealthHandler,
                dict(callback=lambda: self.is_ready_for_browser_connection),
            ),
            (make_url_path_regex(base, "debugz"), DebugHandler, dict(server=self)),
            (make_url_path_regex(base, "metrics"), MetricsHandler),
            (
                make_url_path_regex(base, "message"),
                MessageCacheHandler,
                dict(cache=self._message_cache),
            ),
        ]

        if config.get_option("global.developmentMode") and config.get_option(
            "global.useNode"
        ):
            LOGGER.debug("Serving static content from the Node dev server")
        else:
            static_path = util.get_static_dir()
            LOGGER.debug("Serving static content from %s", static_path)

            routes.extend(
                [
                    (
                        make_url_path_regex(base, "(.*)"),
                        StaticFileHandler,
                        {"path": "%s/" % static_path, "default_filename": "index.html"},
                    ),
                    (make_url_path_regex(base, trailing_slash=False), AddSlashHandler),
                ]
            )

        return tornado.web.Application(routes, **TORNADO_SETTINGS)
Exemple #3
0
    def _create_app(self):
        """Create our tornado web app.

        Returns
        -------
        tornado.web.Application

        """
        routes = [
            (r"/stream", _BrowserWebSocketHandler, dict(server=self)),
            (
                r"/healthz",
                HealthHandler,
                dict(
                    health_check=lambda: self.is_ready_for_browser_connection),
            ),
            (r"/debugz", DebugHandler, dict(server=self)),
            (r"/metrics", MetricsHandler),
            (r"/message", MessageCacheHandler,
             dict(cache=self._message_cache)),
        ]

        if config.get_option("global.developmentMode") and config.get_option(
                "global.useNode"):
            LOGGER.debug("Serving static content from the Node dev server")
        else:
            static_path = util.get_static_dir()
            LOGGER.debug("Serving static content from %s", static_path)

            routes.extend([
                (
                    r"/()$",
                    StaticFileHandler,
                    {
                        "path": "%s/index.html" % static_path
                    },
                ),
                (r"/(.*)", StaticFileHandler, {
                    "path": "%s/" % static_path
                }),
            ])

        return tornado.web.Application(routes, **TORNADO_SETTINGS)
Exemple #4
0
    def _get_routes(self):
        routes = [
            (r'/stream', _BrowserWebSocketHandler, dict(server=self)),
            (r'/healthz', _HealthHandler, dict(server=self)),
            (r'/debugz', _DebugHandler, dict(server=self)),
            (r'/metrics', _MetricsHandler, dict(server=self)),
        ]

        if (config.get_option('global.developmentMode') and
                config.get_option('global.useNode')):
            LOGGER.debug('Serving static content from the Node dev server')
        else:
            static_path = util.get_static_dir()
            LOGGER.debug('Serving static content from %s', static_path)

            routes.extend([
                (r"/()$", tornado.web.StaticFileHandler,
                    {'path': '%s/index.html' % static_path}),
                (r"/(.*)", tornado.web.StaticFileHandler,
                    {'path': '%s/' % static_path}),
            ])

        return routes