当前位置: 首页>>代码示例>>Python>>正文


Python server.Server方法代码示例

本文整理汇总了Python中bokeh.server.server.Server方法的典型用法代码示例。如果您正苦于以下问题:Python server.Server方法的具体用法?Python server.Server怎么用?Python server.Server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.server.server的用法示例。


在下文中一共展示了server.Server方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: finish

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def finish(self):
        if not self.disable_server:

            def modify_doc(doc):
                doc.add_root(self.layout)
                doc.title = self.name

                directory = os.path.abspath(os.path.dirname(__file__))
                theme_path = os.path.join(directory, "theme.yaml")
                template_path = os.path.join(directory, "templates")
                doc.theme = Theme(filename=theme_path)
                env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_path))
                doc.template = env.get_template("index.html")

            self.log.info(
                "Opening Bokeh application on " "http://localhost:{}/".format(self.port)
            )
            server = Server({"/": modify_doc}, num_procs=1, port=self.port)
            server.start()
            server.io_loop.add_callback(server.show, "/")
            server.io_loop.start() 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:23,代码来源:file_viewer.py

示例2: _run_server

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def _run_server(fnc_make_document, iplot=True, notebook_url="localhost:8889", port=80, ioloop=None):
        """Runs a Bokeh webserver application. Documents will be created using fnc_make_document"""
        handler = FunctionHandler(fnc_make_document)
        app = Application(handler)

        if iplot and 'ipykernel' in sys.modules:
            show(app, notebook_url=notebook_url)
        else:
            apps = {'/': app}

            print(f"Open your browser here: http://localhost:{port}")
            server = Server(apps, port=port, io_loop=ioloop)
            if ioloop is None:
                server.run_until_shutdown()
            else:
                server.start()
                ioloop.start() 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:19,代码来源:bokeh_webapp.py

示例3: startServer

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def startServer(self):
        self.server = Server(
            {
                "/devices": self._dev_app_ref(),
                "/trends": self._trends_app_ref(),
                "/notes": self._notes_app_ref(),
            },
            io_loop=IOLoop(),
            allow_websocket_origin=[
                "{}:8111".format(self.IP),
                "{}:5006".format(self.IP),
                "{}:8111".format("localhost"),
                "{}:5006".format("localhost"),
            ],
        )
        self.server.start()
        self.server.io_loop.start() 
开发者ID:ChristianTremblay,项目名称:BAC0,代码行数:19,代码来源:BokehServer.py

示例4: _launcher

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def _launcher(self, obj, threaded=False, io_loop=None):
        if io_loop:
            io_loop.make_current()
        launched = []
        def modify_doc(doc):
            bokeh_renderer(obj, doc=doc)
            launched.append(True)
        handler = FunctionHandler(modify_doc)
        app = Application(handler)
        server = Server({'/': app}, port=0, io_loop=io_loop)
        server.start()
        self._port = server.port
        self._server = server
        if threaded:
            server.io_loop.add_callback(self._loaded.set)
            thread = threading.current_thread()
            state._thread_id = thread.ident if thread else None
            io_loop.start()
        else:
            url = "http://localhost:" + str(server.port) + "/"
            session = pull_session(session_id='Test', url=url, io_loop=server.io_loop)
            self.assertTrue(len(launched)==1)
            return session, server
        return None, server 
开发者ID:holoviz,项目名称:holoviews,代码行数:26,代码来源:testserver.py

示例5: run

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def run(self):
        if hasattr(self, '_target'):
            target, args, kwargs = self._target, self._args, self._kwargs
        else:
            target, args, kwargs = self._Thread__target, self._Thread__args, self._Thread__kwargs
        if not target:
            return
        bokeh_server = None
        try:
            bokeh_server = target(*args, **kwargs)
        finally:
            if isinstance(bokeh_server, Server):
                bokeh_server.stop()
            if hasattr(self, '_target'):
                del self._target, self._args, self._kwargs
            else:
                del self._Thread__target, self._Thread__args, self._Thread__kwargs 
开发者ID:holoviz,项目名称:panel,代码行数:19,代码来源:server.py

示例6: serve_absa_ui

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def serve_absa_ui() -> None:
    """Main function for serving UI application.
    """

    def _doc_modifier(doc: Document) -> None:
        grid = _create_ui_components()
        doc.add_root(grid)

    print("Opening Bokeh application on http://localhost:5006/")
    server = Server(
        {"/": _doc_modifier},
        websocket_max_message_size=5000 * 1024 * 1024,
        extra_patterns=[
            (
                "/style/(.*)",
                StaticFileHandler,
                {"path": os.path.normpath(join(SOLUTION_DIR, "/style"))},
            )
        ],
    )
    server.start()
    server.io_loop.add_callback(server.show, "/")
    server.io_loop.start() 
开发者ID:NervanaSystems,项目名称:nlp-architect,代码行数:25,代码来源:absa_solution.py

示例7: _try_start_web_server

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def _try_start_web_server(self):
        static_path = os.path.join(os.path.dirname(__file__), 'static')

        handlers = dict()
        for p, h in _bokeh_apps.items():
            handlers[p] = Application(FunctionHandler(functools.partial(h, self._scheduler_ip)))

        handler_kwargs = {'scheduler_ip': self._scheduler_ip}
        extra_patterns = [
            ('/static/(.*)', BokehStaticFileHandler, {'path': static_path})
        ]
        for p, h in _web_handlers.items():
            extra_patterns.append((p, h, handler_kwargs))

        retrial = 5
        while retrial:
            try:
                if self._port is None:
                    use_port = get_next_port()
                else:
                    use_port = self._port

                self._server = Server(
                    handlers, allow_websocket_origin=['*'],
                    address=self._host, port=use_port,
                    extra_patterns=extra_patterns,
                    http_server_kwargs={'max_buffer_size': 2 ** 32},
                )
                self._server.start()
                self._port = use_port
                logger.info('Mars UI started at %s:%d', self._host, self._port)
                break
            except OSError:
                if self._port is not None:
                    raise
                retrial -= 1
                if retrial == 0:
                    raise 
开发者ID:mars-project,项目名称:mars,代码行数:40,代码来源:server.py

示例8: bk_worker

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def bk_worker():
    # Note: num_procs must be 1; see e.g. flask_gunicorn_embed.py for num_procs>1
    server = Server({'/bk_sliders_app': bk_sliders.app},
                    io_loop=IOLoop(),
                    address=bk_config.server['address'],
                    port=bk_config.server['port'],
                    allow_websocket_origin=["localhost:8000"])
    server.start()
    server.io_loop.start() 
开发者ID:ioam,项目名称:parambokeh,代码行数:11,代码来源:apps.py

示例9: _start_server

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def _start_server(apps, port, no_browser, path_to_open):
    """Create and start a bokeh server with the supplied apps.

    Args:
        apps (dict): mapping from relative paths to bokeh Applications.
        port (int): port where to show the dashboard.
        no_browser (bool): whether to show the dashboard in the browser

    """
    # necessary for the dashboard to work when called from a notebook
    asyncio.set_event_loop(asyncio.new_event_loop())

    # this is adapted from bokeh.subcommands.serve
    with report_server_init_errors(port=port):
        server = Server(apps, port=port)

        # On a remote server, we do not want to start the dashboard here.
        if not no_browser:

            def show_callback():
                server.show(path_to_open)

            server.io_loop.add_callback(show_callback)

        address_string = server.address if server.address else "localhost"

        print(
            "Bokeh app running at:",
            f"http://{address_string}:{server.port}{server.prefix}/",
        )
        server._loop.start()
        server.start() 
开发者ID:OpenSourceEconomics,项目名称:estimagic,代码行数:34,代码来源:run_dashboard.py

示例10: start_bokeh_server

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def start_bokeh_server(apps):
    from bokeh.server.server import Server

    s = Server(apps) 
开发者ID:mcgillmrl,项目名称:kusanagi,代码行数:6,代码来源:utils_.py

示例11: bkapp_page

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def bkapp_page():
    script = autoload_server(url='http://localhost:5006/bkapp') # switch to server_document when pip uses new version of bokeh, autoload_server is being depreciated
    start_html = '''
    <!doctype html>
    <html lang="en">
      <head>
        <meta charset='utf-8' />
        <meta http-equiv='content-type' content='text/html; charset=utf-8' />
        <title>Streaming with Bokeh Server</title>
      </head>
      <body">'''
    end_html = "</body></html>"   
    return start_html + script + end_html 
开发者ID:pysdr,项目名称:pysdr,代码行数:15,代码来源:rtl_demo_onescript.py

示例12: create_bokeh_server

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def create_bokeh_server(self):
        self.io_loop = IOLoop.current() # creates an IOLoop for the current thread
        # Create the Bokeh server, which "instantiates Application instances as clients connect".  We tell it the bokeh app and the ioloop to use
        server = Server({'/bkapp': self.bokeh_app}, io_loop=self.io_loop, allow_websocket_origin=["localhost:8080"]) 
        server.start() # Start the Bokeh Server and its background tasks. non-blocking and does not affect the state of the IOLoop 
开发者ID:pysdr,项目名称:pysdr,代码行数:7,代码来源:pysdr_app.py

示例13: serve

# 需要导入模块: from bokeh.server import server [as 别名]
# 或者: from bokeh.server.server import Server [as 别名]
def serve(panels, port=0, address=None, websocket_origin=None, loop=None,
          show=True, start=True, title=None, verbose=True, location=True,
          **kwargs):
    """
    Allows serving one or more panel objects on a single server.
    The panels argument should be either a Panel object or a function
    returning a Panel object or a dictionary of these two. If a 
    dictionary is supplied the keys represent the slugs at which
    each app is served, e.g. `serve({'app': panel1, 'app2': panel2})`
    will serve apps at /app and /app2 on the server.

    Arguments
    ---------
    panel: Viewable, function or {str: Viewable or function}
      A Panel object, a function returning a Panel object or a
      dictionary mapping from the URL slug to either.
    port: int (optional, default=0)
      Allows specifying a specific port
    address : str
      The address the server should listen on for HTTP requests.
    websocket_origin: str or list(str) (optional)
      A list of hosts that can connect to the websocket.

      This is typically required when embedding a server app in
      an external web site.

      If None, "localhost" is used.
    loop : tornado.ioloop.IOLoop (optional, default=IOLoop.current())
      The tornado IOLoop to run the Server on
    show : boolean (optional, default=False)
      Whether to open the server in a new browser tab on start
    start : boolean(optional, default=False)
      Whether to start the Server
    title: str or {str: str} (optional, default=None)
      An HTML title for the application or a dictionary mapping
      from the URL slug to a customized title
    verbose: boolean (optional, default=True)
      Whether to print the address and port
    location : boolean or panel.io.location.Location
      Whether to create a Location component to observe and
      set the URL location.
    kwargs: dict
      Additional keyword arguments to pass to Server instance
    """
    return get_server(panels, port, address, websocket_origin, loop,
                      show, start, title, verbose, location, **kwargs) 
开发者ID:holoviz,项目名称:panel,代码行数:48,代码来源:server.py


注:本文中的bokeh.server.server.Server方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。