Interactive plots and applications in the browser from Python
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Comprehensive command-line tools for Bokeh development, deployment, and management. The bokeh command provides subcommands for serving applications, building static content, managing configurations, and working with Bokeh projects.
Commands for running and managing Bokeh server applications.
bokeh serve [OPTIONS] [FILES_OR_DIRS]...Serve Bokeh applications from Python files, directories, or notebooks.
Parameters:
FILES_OR_DIRS: Python files, directories, or Jupyter notebooks to serve--port PORT: Server port (default: 5006)--address ADDRESS: Server bind address (default: localhost)--log-level LEVEL: Log level (trace, debug, info, warn, error, fatal)--log-format FORMAT: Log format (default: standard format)--log-file PATH: Log file path (default: stderr)--args ARGS: Command-line arguments for served applications--show: Open browser automatically--dev: Enable development mode with auto-reload--allow-websocket-origin HOST:PORT: Allow websocket connections from origin--host HOST:PORT: Public hostname for generating URLs--prefix PREFIX: URL prefix for the server--keep-alive MILLISECONDS: Keep-alive ping interval--check-unused-sessions MILLISECONDS: Check for unused sessions interval--unused-session-lifetime MILLISECONDS: Unused session lifetime--stats-log-frequency MILLISECONDS: Stats logging frequency--use-xheaders: Enable X-headers support for reverse proxiesExamples:
# Serve single Python file
bokeh serve myapp.py
# Serve multiple applications
bokeh serve app1.py app2.py --show
# Serve with custom port and development mode
bokeh serve myapp.py --port 8080 --dev
# Serve directory-based application
bokeh serve myproject/ --allow-websocket-origin=example.com:80
# Serve with URL prefix
bokeh serve myapp.py --prefix=/bokeh --port 5007Commands for generating JSON representations of Bokeh content.
bokeh json [OPTIONS] [FILES]...Generate JSON output from Bokeh applications or scripts.
Parameters:
FILES: Python files to process--output PATH: Output file path (default: stdout)--indent SPACES: JSON indentation spaces--args ARGS: Command-line arguments for applicationsExamples:
# Generate JSON from Python file
bokeh json myapp.py --output myapp.json
# Generate formatted JSON
bokeh json myapp.py --indent 2
# Generate JSON with application arguments
bokeh json myapp.py --args "--param value"Commands for building and managing static Bokeh content.
bokeh static [OPTIONS] [DIRECTORY]Build static versions of Bokeh applications for deployment.
Parameters:
DIRECTORY: Target directory for static content--build-dir PATH: Build directory path--verbose: Enable verbose outputExamples:
# Build static content
bokeh static build/
# Build with verbose output
bokeh static build/ --verboseCommands for building Bokeh applications and resources.
bokeh build [OPTIONS]Build Bokeh applications and generate required resources.
Parameters:
--build-dir PATH: Build output directory--rebuild: Force complete rebuild--verbose: Enable verbose build outputExamples:
# Standard build
bokeh build
# Force complete rebuild
bokeh build --rebuild
# Build to specific directory
bokeh build --build-dir ./distCommands for creating new Bokeh projects and applications.
bokeh init [OPTIONS] [DIRECTORY]Initialize a new Bokeh project with template files.
Parameters:
DIRECTORY: Project directory name--template TEMPLATE: Project template to use--force: Overwrite existing filesExamples:
# Create new project
bokeh init myproject
# Create from specific template
bokeh init myproject --template basic
# Force overwrite existing directory
bokeh init myproject --forceCommands for managing Bokeh configuration and settings.
bokeh settings [OPTIONS] [SUBCOMMAND]Manage Bokeh configuration settings and preferences.
Subcommands:
list: List all configuration settingsget KEY: Get specific setting valueset KEY VALUE: Set configuration valuereset: Reset to default settingsExamples:
# List all settings
bokeh settings list
# Get specific setting
bokeh settings get resources.minified
# Set configuration value
bokeh settings set resources.minified false
# Reset all settings
bokeh settings resetCommands for managing secrets and security settings.
bokeh secret [OPTIONS] [SUBCOMMAND]Manage application secrets and security configuration.
Subcommands:
create: Create new secretlist: List existing secretsdelete NAME: Delete secret by nameParameters:
--name NAME: Secret name--value VALUE: Secret value--file PATH: Read secret from fileExamples:
# Create new secret
bokeh secret create --name api_key --value "secret123"
# Create secret from file
bokeh secret create --name certificate --file cert.pem
# List all secrets
bokeh secret list
# Delete secret
bokeh secret delete api_keyCommands for getting information about Bokeh and available functionality.
bokeh info [OPTIONS]Display Bokeh installation and environment information.
Examples:
# Show version and installation info
bokeh info
# Show detailed environment information
bokeh info --verbosebokeh --help
bokeh [COMMAND] --helpDisplay help information for commands.
Examples:
# General help
bokeh --help
# Command-specific help
bokeh serve --help
bokeh json --helpbokeh --versionDisplay Bokeh version information.
# Create new project
bokeh init my_dashboard
# Navigate to project
cd my_dashboard
# Serve in development mode with auto-reload
bokeh serve main.py --dev --show
# Build for production deployment
bokeh build --build-dir ./dist
# Serve production build
bokeh serve dist/ --port 8080 --allow-websocket-origin=mydomain.com:8080# Serve multiple applications on different paths
bokeh serve \
--port 5006 \
dashboard.py \
analytics.py \
monitoring.py \
--show
# Applications will be available at:
# http://localhost:5006/dashboard
# http://localhost:5006/analytics
# http://localhost:5006/monitoring# Production server with reverse proxy support
bokeh serve myapp.py \
--port 5006 \
--address 0.0.0.0 \
--allow-websocket-origin=example.com:80 \
--allow-websocket-origin=example.com:443 \
--prefix=/bokeh \
--use-xheaders \
--log-level info \
--log-file /var/log/bokeh.log# Check current settings
bokeh settings list
# Configure for development
bokeh settings set log.level debug
bokeh settings set resources.minified false
# Configure for production
bokeh settings set log.level warn
bokeh settings set resources.minified true
# Reset to defaults
bokeh settings reset# Generate static HTML files
bokeh json app1.py --output app1.json
bokeh json app2.py --output app2.json --indent 2
# Build static site
bokeh static ./static_site/
# The static files can be served by any web server# Set up application secrets
bokeh secret create --name database_url --value "postgresql://..."
bokeh secret create --name api_key --file ./api_key.txt
# List configured secrets
bokeh secret list
# Applications can access secrets via environment or configAvailable for all commands:
--help: Show help message--version: Show version information--verbose: Enable verbose output--quiet: Suppress non-error output# Configuration
BOKEH_LOG_LEVEL=debug # Set default log level
BOKEH_RESOURCES=inline # Resource loading mode
BOKEH_MINIFIED=false # Use minified resources
# Server settings
BOKEH_PORT=5006 # Default server port
BOKEH_ADDRESS=localhost # Default bind address
BOKEH_ALLOW_WS_ORIGIN=* # Allowed websocket origins
# Development
BOKEH_DEV=true # Enable development mode
BOKEH_PRETTY=true # Pretty-print JSON output# Port specification
PORT := 1024-65535
# Address specification
ADDRESS := IP_ADDRESS | HOSTNAME
# Log levels
LOG_LEVEL := trace | debug | info | warn | error | fatal
# File paths
PATH := ABSOLUTE_PATH | RELATIVE_PATH
# URLs and origins
ORIGIN := PROTOCOL://HOST:PORT
URL_PREFIX := /PATH_SEGMENT
# Time intervals (milliseconds)
MILLISECONDS := INTEGER