[英]flask bokeh server- figure does not render (ubuntu) but works on local machine
I've created a bokeh plot that is accessible through Flask. 我创建了一个可以通过Flask访问的散景图。 I am able to successfully run bokeh server through flask on my local machine via
我能够通过本地计算机上的烧瓶成功运行bokeh服务器
bokeh server bokeh serve--allow-websocket-origin=localhost:5000 filename.py
散景服务器
bokeh serve--allow-websocket-origin=localhost:5000 filename.py
flask python run.py
on two command windows 两个命令窗口上的flask
python run.py
Now I want to do the same thing but on a virtual machine running ubuntu. 现在,我想在运行ubuntu的虚拟机上做同样的事情。 Using the exact same commands on two putty windows no longer work.
在两个腻子窗口上使用完全相同的命令不再起作用。 I am able to access non-bokeh html pages though.
我可以访问非bokeh html页面。
When trying to access the bokeh plot, I get: 当尝试访问散景图时,我得到:
OSError: Cannot pull session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)
OSError:无法提取会话文档,因为我们无法连接到服务器(要启动服务器,请尝试使用“ bokeh serve”命令)
but I already intitiated bokeh serve
但我已经开始使用
bokeh serve
this is the code snippet in flask that will call bokeh server 这是烧瓶中将调用bokeh服务器的代码片段
@main.route("/grid")
def bokehserver():
session=pull_session(url="http://localhost:5006/filename")
bokeh_script=autoload_server(None, url="http://localhost:5006/filename",session_id=session.id)
return render_template("bokserv.html",bokeh_script=bokeh_script)
edit: I'm reading something about 'linux server configuration files' for running bokeh server on linux. 编辑:我正在阅读有关在Linux上运行bokeh服务器的“ Linux服务器配置文件”的内容。 I have not made such configuration files.
我还没有制作这样的配置文件。 Can someone confirm whether these are totally necessary?
有人可以确认这些是否完全必要吗? I don't want to overstuff my project with excess.
我不想过多地增加我的项目。 In many examples I've seen, the developer uses nginx and gunicorn and other things to get flask/bokeh up and running, but so far I've been able to avoid these extra layers..
在我见过的许多示例中,开发人员使用nginx和gunicorn等工具来启动并运行烧瓶/散景,但是到目前为止,我已经能够避免这些额外的层。
edit2: bokeh serve --show filename.py
in the ubuntu terminal generates the standard messages as if it is working but it doesn't open the browser to display the figure. edit2:ubuntu终端中的
bokeh serve --show filename.py
生成标准消息,好像它正在工作,但不会打开浏览器显示该图。
I created the configuration files referenced in the initial post and used bokeh serve --allow-websocket-origin=(my ip):5000 filename.py
. 我创建了初始文章中引用的配置文件,并使用了
bokeh serve --allow-websocket-origin=(my ip):5000 filename.py
。
Then in the flask file from werkzeug.contrib.fixers import ProxyFix
然后在
from werkzeug.contrib.fixers import ProxyFix
的flask文件中from werkzeug.contrib.fixers import ProxyFix
then outside of the app.route(/)
i put app.wsgi_app=ProxyFix(app.wsgi_app)
然后在
app.route(/)
放置app.wsgi_app=ProxyFix(app.wsgi_app)
then I navigated to (my ip):5000
然后我导航到
(my ip):5000
and it worked. 而且有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.