为heroku提供交互式散景图 [英] Serving interactive bokeh figure on heroku

查看:197
本文介绍了为heroku提供交互式散景图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过heroku提供交互式的散景图。我试图服务的图本质上与此相同(示例 code )。我是新来的散景 heroku 所以我敢肯定我失去了一些非常基本的东西 - 我想我想要做的应该是相当简单的。

首先,我可以使用散景服务 - 显示myapp 命令在本地服务我的数字。其中 myapp 是包含散景图的python模块的名称。注意, - show 标志只是提示散景打开浏览器窗口,运行。



接下来,我设置了一个 heroku 帐户,并创建了我的第一个应用程序, Heroku - Python入门教程一>。我的git仓库包含 myapp ,一个 requirements.txt 文件,和 Procfile

唉,有些东西是不行的,我很难过。我在 Procfile 中尝试了一堆不同的选项,但都没有成功。由于散景服务... 命令启动一个服务器,不应该是 Profile 看起来像这样做的伎俩:

  web:bokeh serve --port $ PORT myapp 

这样工作吗?也许我错过了一些东西,我需要创建一个围绕我的散景应用程序的 flask 应用程序,我可以告诉,这似乎不是必要的。也许有人知道一个很好的教程,将所有这些步骤放在一起,我还没有找到一个完整的。

更新:
我在下面粘贴了一些我的 heroku 日志。如何处理 - 主机白名单问题?

  2016- 07-17T05:00:46.513139 + 00:00 heroku [slug-compiler]:弹头编译开始
2016-07-17T05:00:46.366909 + 00:00 heroku [api]:用我@部署9b63d8a。 com
2016-07-17T05:00:46.367087 + 00:00 heroku [api]:发布v4由me@me.com创建
2016-07-17T05:00:46.624937 + 00:00 heroku [web.1]:状态从崩溃改为开始
2016-07-17T05:00:55.188978 + 00:00 heroku [web.1]:用命令bokeh serve --port = 39665 myapp启动进程。 py`
2016-07-17T05:00:57.876287 + 00:00 app [web.1]:2016-07-17 05:00:57,876在端口39665上启动Bokeh服务器,路径为['/ myapp ']
2016-07-17T05:00:57.868758 + 00:00 app [web.1]:2016-07-17 05:00:57,868启动Bokeh服务器版本0.12.0
2016-07 -17T05:00:57.876378 + 00:00 app [web.1]:2016-07-17 05:00:57,876启动进程ID为3
的Bokeh服务器2016-07-17T05:00:58.800309 + 00 :00 heroku [web.1]:从开始状态改变to up
2016-07-17T05:00:59.970326 + 00:00 app [web.1]:2016-07-17 05:00:59,970拒绝主机myapp.herokuapp.com的连接,因为它是不在--host白名单
2016-07-17T05:00:59.973495 + 00:00 app [web.1]:2016-07-17 05:00:59,970 403 GET /(XX.XX.XXX .XX)1.29ms
2016-07-17T05:00:59.975282 + 00:00 heroku [router]:at = info method = GET path =/host = myapp.herokuapp.com request_id = xxxxxxxxxxxxx fwd = XX.XX.XX.XXdyno = web.1 connect = 1ms service = 4ms status = 403 bytes = 219


$ b $

b

我最终得到了如下所示的 Procfile

  web:bokeh serve --port = $ PORT --host = myapp.herokuapp.com --host = * \ 
--address = 0.0.0.0 --use-xheaders myapp。 py

有关这些所有这些的背景nt的意思是(据我所知):

- port :指定端口 bokeh 服务器将监听, $ PORT heroku



- host = myapp.herokuapp.com - host = * :指定主机名为 myapp.heroku ... ,通配符应该允许接受所有主机。我不确定这是需要的。



- address = 0.0.0.0 散景可以自行计算出它的IP地址。



--use-xheaders :导致散景来覆盖远程IP和URI方案/协议

如果这种方法存在问题,我很乐意对此进行编辑或接受更有知识的用户回答。


I'm trying to serve an interactive bokeh figure via heroku. The figure I'm trying to have served is essentially equivalent to this one (example, code). I'm new to both bokeh and heroku so I'm pretty sure I'm missing something pretty basic -- I think what I'm trying to do should be quite straightforward.

First, I can serve my figure locally using the bokeh serve --show myapp command. Where myapp is the name of the python module that includes the bokeh figure. Note that the --show flag just prompts bokeh to open a browser window once the figure is built and the server is running.

Next, I've setup a heroku account, and created my first app, following the steps in the Heroku - Getting Started With Python tutorial. My git repository includes myapp, a requirements.txt file, and Procfile.

Alas, something is not working and I'm stumped. I have tried a bunch of different options in my Procfile and none have worked. Since the bokeh serve ... command starts a server, shouldn't a Profile that looks like this do the trick:

web: bokeh serve --port $PORT myapp

Should that work? Perhaps I'm missing something and I need to create a flask app that wraps around my bokeh app but as far as I can tell, that doesn't seem necessary. Maybe someone knows of a nice tutorial that pulls all of these steps together, I haven't found a complete one yet.

Update: I'm pasting a bit of my heroku logs below. How do you handle this --host whitelist issue?

2016-07-17T05:00:46.513139+00:00 heroku[slug-compiler]: Slug compilation started
2016-07-17T05:00:46.366909+00:00 heroku[api]: Deploy 9b63d8a by me@me.com
2016-07-17T05:00:46.367087+00:00 heroku[api]: Release v4 created by me@me.com
2016-07-17T05:00:46.624937+00:00 heroku[web.1]: State changed from crashed to starting
2016-07-17T05:00:55.188978+00:00 heroku[web.1]: Starting process with command `bokeh serve --port=39665 myapp.py`
2016-07-17T05:00:57.876287+00:00 app[web.1]: 2016-07-17 05:00:57,876 Starting Bokeh server on port 39665 with applications at paths ['/myapp']
2016-07-17T05:00:57.868758+00:00 app[web.1]: 2016-07-17 05:00:57,868 Starting Bokeh server version 0.12.0
2016-07-17T05:00:57.876378+00:00 app[web.1]: 2016-07-17 05:00:57,876 Starting Bokeh server with process id: 3
2016-07-17T05:00:58.800309+00:00 heroku[web.1]: State changed from starting to up
2016-07-17T05:00:59.970326+00:00 app[web.1]: 2016-07-17 05:00:59,970 Rejected connection from host 'myapp.herokuapp.com' because it is not in the --host whitelist
2016-07-17T05:00:59.973495+00:00 app[web.1]: 2016-07-17 05:00:59,970 403 GET / (XX.XX.XXX.XX) 1.29ms
2016-07-17T05:00:59.975282+00:00 heroku[router]: at=info method=GET path="/" host=myapp.herokuapp.com request_id=xxxxxxxxxxxxx fwd="XX.XX.XX.XX" dyno=web.1 connect=1ms service=4ms status=403 bytes=219

解决方案

I'm just going to answer my own question since I was eventually able to get this to work and nobody else has answered it yet.

I ended up with a Procfile that looked like this:

web: bokeh serve --port=$PORT --host=myapp.herokuapp.com --host=* \
     --address=0.0.0.0 --use-xheaders myapp.py

a bit of background on what all of these arguments mean (as far as I can tell):

--port: specifies the port that the bokeh server will listen on, $PORT is set by heroku

--host=myapp.herokuapp.com and --host=*: specify the host name as myapp.heroku..., the wildcard is supposed to allow all hosts to be accepted. I'm not sure this in needed anymore.

--address=0.0.0.0: I think this tells bokeh to figure out on its own, which IP address it will be on.

--use-xheaders: causes bokeh to override the remote IP and URI scheme/protocol

I'm happy to make edits to this or accept a more knowledgeable users answer if there are issues with this approach.

这篇关于为heroku提供交互式散景图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆