我在 heroku 中部署了一個散景應用程式。我想將其嵌入網站,但沒有這樣做。
該應用程式在這里:
https://ckgsb-final.herokuapp.com/cn_ckgsb
這是在網站中使用的腳本:
from bokeh.embed import server_document
script = server_document("https://ckgsb-final.herokuapp.com/cn_ckgsb")
print(script)
<script id="1014">
(function() {
const xhr = new XMLHttpRequest()
xhr.responseType = 'blob';
xhr.open('GET', "https://ckgsb-final.herokuapp.com/cn_ckgsb/autoload.js?bokeh-autoload-element=1014&bokeh-app-path=/cn_ckgsb&bokeh-absolute-url=https://ckgsb-final.herokuapp.com/cn_ckgsb", true);
xhr.onload = function (event) {
const script = document.createElement('script');
const src = URL.createObjectURL(event.target.response);
script.src = src;
document.body.appendChild(script);
};
xhr.send();
})();
</script>
heroku 應用程式的 procfile 是:
web: bokeh serve --port=$PORT --allow-websocket-origin=ckgsb-final.herokuapp.com --address=0.0.0.0 --use-xheaders cn_ckgsb.py
我知道問題出在 websocket 上。我已經在 procfile 和腳本代碼中嘗試了應用程式 url 的各種組合,但沒有設法修復它。
謝謝。
uj5u.com熱心網友回復:
您還需要為嵌入站點的 URL 配置允許的 websocket 源。當用戶導航到mysite.org并且該頁面嘗試嵌入 Bokeh 應用程式時,Bokeh 服務器接收到的 HTTP 源將是mysite.org。如果 Bokeh 服務器未配置為允許該來源,則請求將被拒絕。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/453648.html
下一篇:樣式和格式化文本背景和布局
