由于跨域问题,我无法在已部署的服务器上使用bokeh
绘图。我以几种形式提出了这个问题,并没有真正得到任何结论。
我总是收到错误
XMLHttpRequest cannot load http://127.0.0.1:5006/bokeh/objinfo/0257493b-cce5-450d-8036-2bc57233b1dc/bd1791f4-4d28-4faa-8c9d-a6fe5a1721c1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://my_ip_address' is therefore not allowed access. The response had HTTP status code 500.
我是在运行applet还是尝试嵌入单个绘图。
我在这里尝试从Flask
视图
@perf.route('/_fetch_heatmap', methods=['POST'])
@login_required
def fetch_sd_heatmap():
document = Document()
session = Session(root_url='http://127.0.0.1:5006', configdir=current_app.config['BASE_DIRECTORY'])
session.use_doc('sd_viz')
session.load_document(document)
...
plots = VBox(hm_duration, hm_frequency)
document.add(plots)
push(session, document)
script = autoload_server(plots, session)
return jsonify({'script': script})
此脚本将返回到我的javascript中的ajax
调用。然后将此脚本附加到相应的<div>
这在我的开发机器上运行良好。
以下是我的nginx生产配置
server {
listen my_ip default_server;
charset utf-8;
client_max_body_size 30M;
location ~ ^/(app_config.py|.git) {
deny all;
return 404;
}
location / {
index index.html index.htm;
root /home/myuser/app_directory;
try_files $uri @app;
}
location /static {
alias /home/myuser/app_directory/webapp/static;
}
location @app {
include uwsgi_params;
uwsgi_pass unix:/home/myuser/app_directory/uwsgi.sock;
uwsgi_connect_timeout 18000;
...
}
是否有人成功制作了带有来自生产环境中运行的bokeh
服务器的嵌入式bokeh
图的烧瓶应用程序?
答案 0 :(得分:1)
您好,只是为了更新此讨论,从0.11
中的新Bokeh服务器开始,有更多关于部署的文档:
http://bokeh.pydata.org/en/0.11.1/docs/user_guide/server.html
包括有关在反向代理后面运行的信息,使用负载均衡器和进程管理器以及使用Salt等工具自动执行。永不服务器更健壮,可扩展且易于使用。您可以看到一个现场Bokeh服务器示例库,这些示例已经过&#34;生产&#34;自2016年1月起不断部署:
作为参考,完整的自动部署可用于在GitHub上进行研究:
https://github.com/bokeh/demo.bokehplots.com
此外,在&#34; Happiness&#34;中展示了一个相当复杂的嵌入特定于会话的Bokeh服务器应用程序的示例。例如:
https://github.com/bokeh/bokeh-demos/tree/master/happiness
但最后我应该说,上传0.12
版本将能够为Bokeh应用程序设置一个自定义的Jinja模板,这意味着可以直接从Bokeh文档中构建单页面应用程序。 Bokeh服务器,无需嵌入另一个Web服务器(如果需要)。