☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Stop Server with a button

Community Support
Aemeris
Aemeris

Hi everyone !

I’m trying to stop the localHost with a “Stop” button on my interface, however I can’t find the function to stop the “Curdoc”, could you help me please?

from bokeh.plotting import figure
from bokeh.io import curdoc
from bokeh.models import Button, CustomJS, Div
from bokeh.layouts import column
from bokeh import events

div = Div(width=400)
button = Button(label=“STOP”, width=300)

p = figure(plot_width=400, plot_height=400)

p.square([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=[10, 15, 20, 25, 30], color=“firebrick”, alpha=0.6)

button.js_on_event(events.ButtonClick, CustomJS(args=dict(div=div), code=“”"
div.text = “Stop server”;
“”"))
doc=curdoc()
doc.add_root(column(p,button))

Best Regards,
Pierre-yves

⌁   Link to post
p-himik
p-himik
from tornado.ioloop import IOLoop

from bokeh.io import curdoc
from bokeh.layouts import column
from bokeh.models import Button
from bokeh.plotting import figure


def stop_server():
    IOLoop.current().stop()


p = figure()
p.circle(0, 0)

button = Button(label="STOP")
button.on_click(stop_server)
curdoc().add_root(column(p, button))
⌁   Link to post

End of archived discussion · Replies are disabled