Trying to get a simple working panel/bokeh server on my web server.
I have embed.html
<head>
{{ resources|safe }}
</head>
{% block content %}
<h1>Plot should be here.</h1>
<div>
{{ div|safe }}
{{ script|safe }}
</div>
{% endblock %}
panel_test.py
def sine(frequency, phase, amplitude):
xs = np.linspace(0, np.pi*4)
return hv.Curve((xs, np.sin(frequency*xs+phase)*amplitude)).options(width=800)
if __name__ == '__main__':
ranges = dict(frequency=(1, 5), phase=(-np.pi, np.pi), amplitude=(-2, 2), y=(-2, 2))
dmap = hv.DynamicMap(sine, kdims=['frequency', 'phase', 'amplitude']).redim.range(**ranges)
pn.serve(dmap, port=5006, allow_websocket_origin=["localhost:5000"], show=False,threaded=True)
main_test.py
app = Flask(__name__)
application=app
# locally creates a page
@app.route('/')
def index():
script = server_document(url='localhost:5006')
# print(script)
# use the script in the rendered page
print("Session Pulled!", datetime.now())
print(script)
return render_template("embed.html", script=script)
if __name__ == '__main__':
# runs app in debug mode
app.run(port=5000, debug=True)
After firing up panel_test.py I get confirmation that the panel is running
Which is great. Then running my main_test.py on my server it seems to communcate with localhost but I get a webpage with just 'Plot should be here' (as expected) and nothing else. Upon looking at the source code it looks like render_template has inserted the 'script' code (See below) but does not seem to be rendering the images:
var xhr = new XMLHttpRequest()
xhr.responseType = 'blob';
xhr.open('GET', "localhost:5006/autoload.js?bokeh-autoload-element=1002&bokeh-app-path=/localhost:5006&bokeh-absolute-url=localhost:5006", true);
xhr.onload = function (event) {
var script = document.createElement('script'),
src = URL.createObjectURL(event.target.response);
script.src = src;
document.body.appendChild(script);
};
xhr.send();
Has anyone encountered this?