3

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.

アプレットを実行しているか、単一のプロットを埋め込もうとしているか。

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})

ajaxこのスクリプトは、私の JavaScript 内の呼び出しに返されます。このスクリプトは、対応する<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

4

1 に答える 1