I have written a very simple flask application to test out Bokeh, however my Bokeh line chart just wont render. All it shows is :
My html is:
<html>
<head>
<meta charset="UTF-8">
<link href="http://cdn.bokeh.org/bokeh/release/bokeh-2.0.0.min.css" rel="stylesheet" type="text/css">
<script src="http://cdn.bokeh.org/bokeh/release/bokeh-2.0.0.min.js"></script>
</head>
<body>
{{graph | safe}}
</body>
</html>
My flask function is:
app.route('/result')
def result():
x = [1, 3, 5, 7]
y = [2, 4, 6, 8]
p = figure()
p.circle(x, y, size=10, color='red', legend='circle')
p.line(x, y, color='blue', legend='line')
p.triangle(y, x, color='gold', size=10, legend='triangle')
return render_template("result.html", graph=p)
The version of bokeh currently installed by pip is 2.0.0
You can't just pass a bare Bokeh object to a Jinja template. There are various Bokeh APIs for embedding the content in different ways. You will need to use one of those:
https://docs.bokeh.org/en/2.0.0/docs/user_guide/embed.html
For standalone content like this you either want json_items
, components
, or autoload_static
.