Search code examples
bokeh

Pass command line arguments to Bokeh server application


I have a Bokeh server application. I would like to pass it custom options on the command line:

bokeh serve /path/to/script.py --my-option foo

Is this possible? Will Bokeh pass these options through somehow?


Solution

  • Yes, use the --args command line option described in the User's Guide. Everything you put after the --args option will just appear in sys.argv for the app code, just as you would expect with any normal python script.

    Running this app:

    import sys
    print(sys.argv)
    

    With this invocation:

    bokeh serve foo.py --args -x 1 bar --baz
    

    Then opening a session will result in this being printed:

    ['foo.py', '-x', '1', 'bar', '--baz']