2017-03-28 58 views
0

我想弄清楚如何結合散景和heroku。 當我在本地運行下面的代碼,我得到以下輸出:如何在heroku上運行散景應用程序

enter image description here 但是,在hereku,我得到一個空的瀏覽器頁面。所以我不知道你是否是我的錯。你能幫我解決嗎?下面是我的代碼使用方法:

mytest.py

import numpy as np 
from numpy import pi 

from bokeh.client import push_session 
from bokeh.driving import cosine 
from bokeh.plotting import figure, curdoc 

x = np.linspace(0, 4*pi, 80) 
y = np.sin(x) 

p = figure() 
r1 = p.line([0, 4*pi], [-1, 1], color="firebrick") 
r2 = p.line(x, y, color="navy", line_width=4) 

# open a session to keep our local document in sync with server 
session = push_session(curdoc()) 

@cosine(w=0.03) 
def update(step): 
    # updating a single column of the the *same length* is OK 
    r2.data_source.data["y"] = y * step 
    r2.glyph.line_alpha = 1 - 0.8 * abs(step) 

curdoc().add_periodic_callback(update, 50) 

session.show(p) # open the document in a browser 

session.loop_until_closed() # run forever 

requirements.txt

appdirs==1.4.3 
backports-abc==0.5 
bokeh==0.12.4 
certifi==2017.1.23 
futures==3.0.5 
Jinja2==2.9.5 
MarkupSafe==1.0 
numpy==1.12.1 
packaging==16.8 
pyparsing==2.2.0 
python-dateutil==2.6.0 
PyYAML==3.12 
requests==2.13.0 
singledispatch==3.4.0.3 
six==1.10.0 
tornado==4.4.2 

Proctofile

web: bokeh serve --port=$PORT --host=protected-sands-65334.herokuapp.com --host=* --address=0.0.0.0 --use-xheaders mytest.py 

回答

0

我把它通過刪除代碼行描述會話,並增加工作如下:

curdoc().add_root(p) 

另外,請注意該文件包含的命令名稱來運行的背景虛化服務器應該Procfile,沒有別的(你輸入Proctofile)。

+0

添加更多信息 –

相關問題