def __init__(self, flask_app, **settings):
        self.flask_app = flask_app
        tornado_flask = WSGIContainer(flask_app)
        url_prefix = server_settings.url_prefix
        handlers = [
            (url_prefix + "/bokeh/sub", WebSocketHandler),
            (r".*", FallbackHandler, dict(fallback=tornado_flask))
        ]
        super(TornadoApplication, self).__init__(handlers, **settings)
        self.wsmanager = WebSocketManager()

        def auth(auth, docid):
            if docid.startswith("temporary-"):
                return True
            doc = docs.Doc.load(bokeh_app.servermodel_storage, docid)
            status = mconv.can_read_doc_api(doc, auth)
            return status
        self.wsmanager.register_auth('bokehplot', auth)

        self.subscriber = PingingSubscriber(server_settings.ctx,
                                            [server_settings.sub_zmqaddr],
                                            self.wsmanager)
        self.forwarder = Forwarder(server_settings.ctx,
                                   server_settings.pub_zmqaddr,
                                   server_settings.sub_zmqaddr)
예제 #2
0
from __future__ import print_function
from os.path import join, dirname, abspath
import time

from bokeh.server.settings import settings as server_settings
from bokeh.server.forwarder import Forwarder

if __name__ == "__main__":
    config_file = abspath(join(dirname(__file__), 'config.py'))
    print(config_file)
    server_settings.from_file(config_file)
    forwarder = Forwarder(server_settings.ctx, server_settings.pub_zmqaddr,
                          server_settings.sub_zmqaddr)
    try:
        forwarder.start()
        while True:
            time.sleep(10)
    except KeyboardInterrupt:
        forwarder.stop()
예제 #3
0
from os.path import join, dirname
import time

from bokeh.server.settings import settings as server_settings
from bokeh.server.forwarder import Forwarder

if __name__ == "__main__":
    config_file = join(dirname(__file__), 'config.py')
    server_settings.from_file(config_file)
    forwarder = Forwarder(server_settings.ctx,
                          server_settings.pub_zmqaddr,
                          server_settings.sub_zmqaddr)
    try:
        forwarder.start()
        while True:
            time.sleep(10)
    except KeyboardInterrupt:
        forwarder.stop()