def start(self, httpPort = 9999):
        # Create multiplexer
        router = MultiplexConnection.get(ann=ConnectionPlot, bob=ConnectionClassLabel)

        # Register multiplexer
        EchoRouter = SockJSRouter(router, '/echo')

        # Web server root dir
        wwwroot = os.path.abspath(os.path.dirname(__file__)) + "/www"

        # Create application
        app = tornado.web.Application(
                EchoRouter.urls +
                [
                    # special handler for index.html, because it's default and you don't actually type index.html
                    (r"/", VisualizationServer.IndexHandler),
                    # all other static files just go direct to www folder
                    (r"/(.*)", tornado.web.StaticFileHandler, {"path": wwwroot})
                ]
        )
        app.listen(httpPort)

        if self.debug:
            print self.LOGNAME + "started on port " + str(httpPort)
            print self.LOGNAME + "all web requests routed to " + wwwroot
            print self.LOGNAME + "Visit visualization server by pointing your web browser to http://localhost:" + str(httpPort) + "/index.html"

        # start the tornado server
        tornado.ioloop.IOLoop.instance().start()
    def start(self, httpPort=9999):
        # Create multiplexer
        router = MultiplexConnection.get(ann=ConnectionPlot,
                                         bob=ConnectionClassLabel)

        # get config from yaml file
        settings_file_path = os.path.realpath(
            os.path.join(os.getcwdu(), self.conf_path))
        stream = file(settings_file_path, 'r')
        # set conf on all multiplexer channels from the yaml config file
        router.set_conf(yaml.load(stream))

        # Register multiplexer
        EchoRouter = SockJSRouter(router, '/echo')

        # Create application
        app = tornado.web.Application(
            EchoRouter.urls + [
                # special handler for index.html, because it's default and you don't actually type index.html
                (r"/", VisualizationServer.IndexHandler),
                # html files are treated as templates
                (r"(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*\.(?:html))?",
                 VisualizationServer.MainHandler),
                # all other static files just go direct to www folder
                (r"/(.*)", tornado.web.StaticFileHandler, {
                    "path": self.wwwroot
                })
            ],
            static_path=self.wwwroot,
            template_path=self.wwwroot,
            debug=True)
        app.listen(httpPort)

        if self.debug:
            print self.LOGNAME + "Started - all web requests routed to " + self.wwwroot
            print self.LOGNAME + "Visit visualization server by pointing your web browser to http://localhost:" + str(
                httpPort) + "/index.html"

        # start the tornado server
        tornado.ioloop.IOLoop.instance().start()
Example #3
0
    def start(self, httpPort = 9999):
        # Create multiplexer
        router = MultiplexConnection.get(ann=ConnectionPlot, bob=ConnectionClassLabel)

        # get config from yaml file
        settings_file_path = os.path.realpath( os.path.join( os.getcwdu(), self.conf_path) )
        stream = file(settings_file_path, 'r')
        # set conf on all multiplexer channels from the yaml config file
        router.set_conf(yaml.load(stream))

        # Register multiplexer
        EchoRouter = SockJSRouter(router, '/echo')

        # Create application
        app = tornado.web.Application(
                EchoRouter.urls +
                [
                    # special handler for index.html, because it's default and you don't actually type index.html
                    (r"/", VisualizationServer.IndexHandler),
                    # html files are treated as templates
                    (r"(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*\.(?:html))?", VisualizationServer.MainHandler),
                    # all other static files just go direct to www folder
                    (r"/(.*)", tornado.web.StaticFileHandler, {"path": self.wwwroot})
                ],
                static_path=self.wwwroot,
                template_path=self.wwwroot,
                debug=True
        )
        app.listen(httpPort)

        if self.debug:
            print self.LOGNAME + "Started - all web requests routed to " + self.wwwroot
            print self.LOGNAME + "Visit visualization server by pointing your web browser to http://localhost:" + str(httpPort) + "/index.html"

        # start the tornado server
        tornado.ioloop.IOLoop.instance().start()