I am running a flask script that calls a bokeh graph generator to create a script and four divs on load.
plots = {'temperature': t.get_plot(), 'humidity': h.get_plot(), 'light':
l.get_plot(), 'combined': c.get_plot()}
script, divs = components(plots)
return script, divs['temperature'], divs['humidity'], divs['light'],
divs['combined']
and rendering template in start_app.py
@app.route('/')
def index():
script, temperature, humidity, light, combined =
serial_ops.create_graphs()
return render_template("index.html", script=script,
temperature=temperature, humidity=humidity, light=light, combined=combined)
and I am rendering it to a template that looks like this.
{% extends "bootstrap/base.html" %}
{% block title %}RPI Flask Test{% endblock %}
{% block scripts %}
<link href="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.5.min.css" rel="stylesheet" type="text/css">
<script src="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.5.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type=text/javascript>
{% endblock %}
{% block content %}
{{ script|safe }}
<div class="container-fluid">
<div class="row">
<div class="col-md-4">
<div id="temperature">
{{ temperature|safe }}
</div>
</div>
... etcetera ...
There is some info about Bokeh embedding here, including examples of what the script / div may look like. http://docs.bokeh.org/en/latest/docs/user_guide/embed.html
I looked at a few examples and tutorials online, but I couldn't figure out how to update these scripts and divs without refreshing the page. Most examples use id=#x. I figure there are some other ways I could do it with iframes, but I'd prefer to try an AJAX solution before that. Currently I am not using Bokeh-Server as there are no interactions, and a slow refresh rate.
Thanks