Source code for bokeh.command.subcommands.static

#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2018, Anaconda, Inc. All rights reserved.
#
# Powered by the Bokeh Development Team.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Boilerplate
#-----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function, unicode_literals

import logging
log = logging.getLogger(__name__)

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

# Standard library imports

# External imports

# Bokeh imports
from bokeh.util.logconfig import basicConfig

from ..subcommand import Subcommand
from ..util import report_server_init_errors
from .serve import base_serve_args


#-----------------------------------------------------------------------------
# Globals and constants
#-----------------------------------------------------------------------------

__all__ = (
    'Static',
)

#-----------------------------------------------------------------------------
# General API
#-----------------------------------------------------------------------------

[docs]class Static(Subcommand): ''' Subcommand to launch the Bokeh static server. ''' #: name for this subcommand name = "static" help = "Serve bokehjs' static assets (JavaScript, CSS, images, fonts, etc.)" args = base_serve_args
[docs] def invoke(self, args): ''' ''' # protect this import inside a function so that "bokeh info" can work # even if Tornado is not installed from bokeh.server.server import Server log_level = getattr(logging, args.log_level.upper()) basicConfig(level=log_level, format=args.log_format) applications = {} _allowed_keys = ['port', 'address'] server_kwargs = { key: getattr(args, key) for key in _allowed_keys if getattr(args, key, None) is not None } with report_server_init_errors(**server_kwargs): server = Server(applications, **server_kwargs) address_string = '' if server.address is not None and server.address != '': address_string = ' address ' + server.address log.info("Starting Bokeh static server on port %d%s", server.port, address_string) server.run_until_shutdown()
#----------------------------------------------------------------------------- # Dev API #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Private API #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Code #-----------------------------------------------------------------------------