我将我的应用程序部署到Heroku但它没有运行!
这是“git push heroku master”命令的输出:
-----> Python app detected
-----> Using Python runtime (python-2.7.8)
-----> Installing dependencies using Pip (1.5.6)
Cleaning up...
-----> Discovering process types
Procfile declares types -> web
-----> Compressing... done, 37.6MB
-----> Launching... done, v5
http://xxxxx.herokuapp.com/ deployed to Heroku
To git@heroku.com:xxxxx.git
46ff457..1712c4b master -> master
我的Procfile的内容:
web: python main.py
我的main.py:
import bottle
import os
@bottle.route("/request")
def tryquestion():
return '''
<form action="/request" method="post">
Enter you request: <input name="request" type="text" size="65" />
<input value="Search" type="submit" />
</form>
'''
@bottle.route("/request", method="POST")
def answerq():
q = request.forms.get('request')
##### my code #####
bottle.run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))
日志文件:
2014-07-15T16:24:45.361567+00:00 app[web.1]: Traceback (most recent call last):
2014-07-15T16:24:45.361592+00:00 app[web.1]: from umbc2 import sss
2014-07-15T16:24:45.361599+00:00 app[web.1]: from requests import get
2014-07-15T16:24:45.361641+00:00 app[web.1]: ImportError: No module named reques
ts
2014-07-15T16:24:46.801880+00:00 heroku[web.1]: State changed from starting to c
rashed
2014-07-15T16:24:46.791054+00:00 heroku[web.1]: Process exited with status 1
2014-07-15T19:32:07.105615+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=xxxx.herokuapp.com request_id=d9d90a2b-8367
-4b3d-94b8-aecf5c2700a8 fwd="99.231.120.219" dyno= connect= service= status=503
bytes=
2014-07-15T19:32:07.254940+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=xxxx.herokuapp.com request_id=f3
0601cc-9703-494e-83ff-7ea3b95aea81 fwd="99.231.120.219" dyno= connect= service=
status=503 bytes=
2014-07-15T19:32:07.304050+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/favicon.ico" host=xxxx.herokuapp.com request_id=cd
1ff90b-6644-4f79-b0fc-745f0480c3b7 fwd="99.231.120.219" dyno= connect= service=
status=503 bytes=
2014-07-15T19:32:26.459193+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/result" host=xxxx.herokuapp.com request_id=93a8d94
9-8f1b-4f1b-ad00-a1cbf8167bef fwd="99.231.120.219" dyno= connect= service= statu
s=503 bytes=
检查日志后,它会在导入请求时出错。我向需求文件添加了请求,应用程序已启动并运行。
感谢所有人的帮助
答案 0 :(得分:0)
为heroku运行瓶子应用程序你需要这些规范
首先procfile添加此
web:python ./main.py $ PORT
并确保您有需求文件添加瓶子。