Deploy a bokeh app in the template directory structure

Hi there,

I am currently running my bokeh application by executing

subprocess.call(["bokeh", "serve", "--show", myapp)

My app is in the template directory format and uses the template just fine.

To run the app in “flask-mode” I run:

subprocess.call(["bokeh", "serve", myapp, "--allow-websocket-origin=127.0.0.1:8080")
Flask part
from flask import Flask, render_template_string
from bokeh.embed import server_document

application = Flask(__name__)

index_str = """
<div>
    {{ tag | safe }}
</div>
"""

@application.route("/")
def index():
    tag = server_document(url="http://localhost:5006/myapp")
    return render_template_string(index_str, tag=tag)


if __name__ == "__main__":
    application.run(port=8080)

Now the question:
I managed to make the flask server pick up the bokeh app successfully, however it does not use the template. How do I deploy a “templated” bokeh app? Do I have to copy most of the contents of the bokeh template to the flask template?

I was thinking that Flask just “forwards” the contents of the bokeh-app at the specified URL (which would include the bokeh-template).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.