Search code examples
python-3.xbokeh

How to run a bokeh server without 'bokeh server --show' command?


I want to run a bokeh interactive application without using "bokeh serve --show" command. Instead, I want to use 'python script_name.py' syntax. Is there any way to do this?


Solution

  • This is covered in the project documentation:

    https://docs.bokeh.org/en/latest/docs/user_guide/server.html#embedding-bokeh-server-as-a-library

    from bokeh.server.server import Server
    
    server = Server(
        bokeh_applications,  # list of Bokeh applications
        io_loop=loop,        # Tornado IOLoop
        **server_kwargs      # port, num_procs, etc.
    )
    
    # start timers and services and immediately return
    server.start()