On Jun 17, 2016, at 7:15 AM, [email protected] wrote:
I've the exact same use case with a Flask app.
After a quick test and reading the docs, to use on_change event handlers you have to run your Python code with bokeh serve <app>.
You can't just send everything using autoload_server.
As I see it, you have 2 ways to do it:
1. Put all your bokeh code in foo.py and run bokeh serve foo.py
In your django app, you just call autoload_server to embed the entire document.
return autoload_server(model=None, app_path='/foo')
2. If you want to keep the bokeh code in your django app, you have to use a CustomJS callback.
As I see it, the solution 1 makes it easier to add interaction to your plot.
The drawback is that anyone can access /foo on the bokeh server directly.
In my case, I have some user authentication in my Flask app I'd like to use.
I might get around by only allowing localhost to access the bokeh server.
Or I might go for solution 2. I haven't decided yet.
Le vendredi 10 juin 2016 12:23:22 UTC, [email protected] a écrit :
I have a use case where I would like an interactive plot controlled by a slider embedded in a Django webserver (using autoload_server). However, the slider is not responding, most likely due to a lack of polling of the client. What is the proper way to poll for responses when using autoload_server? Where would you add session.loop_until_closed()? When I add it, the loop blocks everything.
The slider has working callbacks set up and it works when served on the bokeh server. This is the function i use to communicate with the server:
def get_bokeh_script(plot, suffix):
document = Document()
document.title = suffix
with closing(push_session(document)) as session:
# Get the script to pass into the template
script = autoload_server(None, session_id=session.id)
and the slider is in the argument passed via plot as follows:
def update(attrname, old, new):
source.data = compute(sTime.value, params)
sTime = Slider(title="Time (h)", value=0, start=0, end=max(data['times']), step=max(data['times']) / 25)
update(None, None, None)
plot= VBoxForm(release, time_plot, sTime)
where release and time_plot are Figure objects.
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a8626b76-f536-42b1-b441-d1b9031504b3%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.