Embedding bokeh server in flask app on Windows 10

I have been trying for some time now to duplicate an example showing how to embed a bokeh sever app into an HTML document using Flask. Unfortunately, after executing my code, the browser doesn’t show the expected bokeh server app embedded in the HTML as it should. Surprisingly, if the same code is run on a Windows 8.1 OS, the app is rendered correctly, embedding it in the HTML document.

I am using the following module versions (from Anaconda3) on a Windows 10 OS platform:

Python 3.7.3
Bokeh 1.2.0
Flask 1.0.2

the rand_gen.py file - bokeh app being embedded

from bokeh.io import curdoc
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from random import randrange

#create figure
f=figure(x_range=(0,11),y_range=(0,11))

#create columndatasource
source=ColumnDataSource(data=dict(x=,y=))

#create glyphs
f.circle(x=‘x’,y=‘y’,size=8,fill_color=‘olive’,line_color=‘yellow’,source=source)

#create periodic function
def update():
new_data=dict(x=[randrange(1,10)],y=[randrange(1,10)])
source.stream(new_data,rollover=15)
#print(source.data)

#add figure to curdoc and configure callback
curdoc().add_root(f)
curdoc().add_periodic_callback(update,1000)

Flask code (app.py)

from flask import Flask, render_template
from bokeh.embed import server_session
from bokeh.client import pull_session

#instantiate the flask app
app = Flask(name)

#create index page function
@app.route(“/”, methods=[‘GET’])
def index():
rg_url = “http://localhost:5006/rand_gen
session = pull_session(url=rg_url)
bscript = server_session(None, session.id, url=rg_url)
return render_template(“index.html”, bscript=bscript, template=‘Flask’)

#run the app
if name == “main”:
app.run(port=5000 debug=True)

index.html

I am the title

I am a heading

{{bscript|safe}}

I am a paragraph

so to execute this, I invoke the bokeh server, specifically setting the websocket origins for both port 5000 and 5006.

bokeh serve rand_gen.py --allow-websocket-origin=localhost:5006 --allow-websocket-origin=localhost:5000

then in another cmd prompt, I execute the flask app invoking python on the file :
python app.py

running the code on Windows 10, after opening browser windows for each of the localhost URLs, I only see the original bokeh app running on port 5006. the browser display on port 5000 shows only the HTML template with no bokeh app embedded within.

however running this code on Windows 8.1 OS --using the same python and module versions stated above-- the result is a success. the browser shows a plot of random dots, between 2 headings, updating their random placement.

why does this code only work on an older win 8.1 OS and not win 10? I’m puzzled to say the least. can anyone explain a cause and possible solution for this? thanks

-Darren

Possibly a bug. Despite asking many times over the years for someone to step up as the “Windows Maintainer” for Bokeh, no one has yet decided they want the job. None of the current core devs use Windows regularly, so Windows functionality is definitely a weak spot for testing/maintenance. I’d encourage you to file an issue on GitHub, with as much information as possible, especially any server or browser JS console log messages.