Panel 0.10.3 and bokeh 2.2.3 server_document shows blank in flask

I have been running panel/bokeh server and having flask display the panel apps on the same machine (vm) for a while. This is my script inside flask per bokeh documentation:

script = server_document(url="", arguments={'user': user_name, 'project':project})
return render_template("page.html", user_name=user_name, project=project, script=script, template="Flask")

Since upgrading to panel 0.10.3 and bokeh 2.2.3, the flask page is drawing up blank. Firebug shows errors:

failed to load http://localhost/apps/static/extensions/panel/panel.min.js

It works again with no errors when I downgraded to panel 0.9.5 and bokeh version to 2.0.0! I am running Python 3.7.6 and Flask 1.1.2.

Can someone suggest what I can do to make the flask display the panel apps with the latest versions?


See this topic to see if it addresses your issues.

1 Like

Thank you so much for suggesting that workaround. I included the following in my file that flasks uses to generate the endpoints

from bokeh.settings import settings

settings.resources = 'inline'

Unfortunately, that didn’t solve my issue.

I also came across this thread that suggested something similar

I tried setting the environment variable by

export BOKEH_RESOURCES=inline

I also tried adding this to my supervisor conf.d


None of these helped.
I would appreciate any other ideas or suggestions.

Hi @kmallick2000

I’m sorry things did not work in the initial attempt.

In my setup, where a Flask app is running as a separate webserver and pulling in the panel/bokeh application, the workaround cited is added to the bokeh server app code whereas you’ve added that to your Flask app if I understand the steps tried.

I will add that the regression I encountered with bokeh 2.2.3 and panel 0.10.2 was resolved with a development branch pointed to by @philippjfr and that was supposedly part of the recent 0.10.3 release that you’re using.

For what it’s worth, my app is using panel 0.10.2 (with the workaround cited) in conjunction with bokeh 2.2.3 and Flask 1.1.2 and deployed on Heroku under the Python 3.8.7 environment.

1 Like

Really appreciate your continued help.
Finally success!

My bokeh serve command is called from supervisor. Hence my initial attempt to set the BOKEH_RESOURCES variable was in that file. However it didn’t have any effect in the [supervisorctl] block, which I thought was appropriate for the environment variable.

I decided to move it to the [bokehserver] block in conf.d file of supervisor and now it works: the flask is able to embed the panel app.

Here is a sample [bokehserver] block from my conf.d file of supervisor, just in case it helps somebody looking for clarity.

command = /home/ubuntu/anaconda3/envs/myenv/bin/bokeh serve app1 app2 app3

Well, this is quite embarrassing! I swear it was working, and now its not anymore. I can see the panel app in action, but flask cannot seem to display the app using the server-document method. And even more strange, the firebug does not show any error at all.

Its all good and it works. The problem I ran into was due to missing the http:// part of
script = server_document(url=“http://localhost/apps/app1”)

1 Like