本文整理匯總了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()
示例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()
示例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()
示例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
示例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
示例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()
示例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
示例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()
示例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()
示例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)
示例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
示例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
示例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)