我是python和flask的新手。 该烧瓶的文档说您可以将您的应用程序部署到heroku以供公众访问。所以我转向了heroku网站。我一步一步地跟着入门指南。我成功部署了应用程序,但是当我使用https://mighty-falls-2223.heroku.com/之类的给定网址进行测试时,它表示存在错误。
错误消息是:
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
我试过heroku logs命令:
2015-02-06T05:05:23.598482+00:00 heroku[api]: Release v2 created by kelvintgx@yahoo.com
2015-02-06T05:05:23.598482+00:00 heroku[api]: Enable Logplex by kelvintgx@yahoo.com
2015-02-06T05:43:45.975680+00:00 heroku[api]: Deploy 6c41484 by kelvintgx@yahoo.com
2015-02-06T05:43:45.975680+00:00 heroku[api]: Release v3 created by kelvintgx@yahoo.com
2015-02-06T05:45:21.762316+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=a2351725-38cb-4480-a97a-b9cf84b1c8ec fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-06T05:45:24.285661+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=mighty-falls-2323.herokuapp.com request_id=80d64b3a-3da7-4836-a653-0040b43acd0a fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-06T05:45:58.722807+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/" host=mighty-falls-2323.herokuapp.com request_id=5864f9d0-f4cb-438d-acc6-74c1afb05188 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-06T05:46:20.066306+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=1b62f73b-3240-4428-bc77-112801685486 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-06T05:47:57.279689+00:00 heroku[api]: Deploy 6c41484 by kelvintgx@yahoo.com
2015-02-06T05:47:57.279689+00:00 heroku[api]: Release v4 created by kelvintgx@yahoo.com
2015-02-06T06:02:22.868450+00:00 heroku[api]: Release v5 created by kelvintgx@yahoo.com
2015-02-06T06:02:22.868450+00:00 heroku[api]: Deploy 38003ed by kelvintgx@yahoo.com
2015-02-06T06:02:41.211691+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=0be3ab2e-e3d3-4186-8ae2-fddcd5919f11 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-06T06:03:12.755692+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=dbdcb909-ee4a-4c37-ade0-a2f38d9bad3e fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-06T06:03:58.407684+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=52d528be-0e19-491d-b80f-a6ed468a687c fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-06T06:08:41.991908+00:00 heroku[api]: Deploy 9d0211e by kelvintgx@yahoo.com
2015-02-06T06:08:41.991908+00:00 heroku[api]: Release v6 created by kelvintgx@yahoo.com
2015-02-06T06:09:11.138002+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=c2164d36-0c85-43fb-87d0-d637b011116e fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-06T06:09:37.362330+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=49c04057-1a7b-432d-a8a8-7d5687b717d1 fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-06T06:10:15.040200+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/index.py/test" host=mighty-falls-2323.herokuapp.com request_id=ef7a49b4-fc15-4876-ae0a-30c866fb6ccd fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-06T08:03:09.470102+00:00 heroku[api]: Release v7 created by kelvintgx@yahoo.com
2015-02-06T08:03:09.470102+00:00 heroku[api]: Deploy 9d0211e by kelvintgx@yahoo.com
2015-02-06T08:03:38.874551+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=3e7ebf43-d55f-4831-98ee-3758957c6110 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-06T10:21:31.070674+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=8c2a7f5b-3382-4685-9e50-8415fbfc8703 fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-06T10:25:42.879279+00:00 heroku[api]: Starting process with command
false&&自动诊断由HEROKU支持运行; cat Procfile by kelvintgx@yahoo.com
2015-02-06T10:25:46.887330+00:00 heroku[run.4361]: Awaiting client
2015-02-06T10:25:46.921078+00:00 heroku[run.4361]: Starting process with command
false&&自动诊断由HEROKU支持运行; cat Procfile
2015-02-06T10:25:48.553909+00:00 heroku[api]: Starting process with command
false&&自动诊断由HEROKU支持运行; cat requirements.txt by kelvintgx@yahoo.com
2015-02-06T10:25:47.174906+00:00 heroku[run.4361]: State changed from starting to up
2015-02-06T10:25:49.052088+00:00 heroku[run.4361]: Process exited with status 0
2015-02-06T10:25:49.061559+00:00 heroku[run.4361]: State changed from up to complete
2015-02-06T10:25:55.154435+00:00 heroku[run.5301]: Awaiting client
2015-02-06T10:25:55.187005+00:00 heroku[run.5301]: Starting process with command
false&&自动诊断由HEROKU支持运行; cat requirements.txt
2015-02-06T10:25:55.608338+00:00 heroku[run.5301]: State changed from starting to up
2015-02-06T10:25:57.225198+00:00 heroku[run.5301]: Process exited with status 0
2015-02-06T10:25:57.237272+00:00 heroku[run.5301]: State changed from up to complete
2015-02-06T10:41:02.655049+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=88ad749c-b3c0-41da-8522-052c25beaa58 fwd="82.227.198.77" dyno= connect= service= status=503 bytes=
2015-02-06T10:41:02.986494+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=mighty-falls-2323.herokuapp.com request_id=3cb538b8-7020-49c5-8d5f-4752ed41bf17 fwd="82.227.198.77" dyno= connect= service= status=503 bytes=
2015-02-06T10:41:14.129885+00:00 heroku[api]: Starting process with command
bash by damien@heroku.com
2015-02-06T10:41:18.300710+00:00 heroku[run.5301]: Awaiting client
2015-02-06T10:41:18.335348+00:00 heroku[run.5301]: Starting process with command
bash
2015-02-06T10:41:18.590203+00:00 heroku[run.5301]: State changed from starting to up
2015-02-06T10:41:23.138727+00:00 heroku[run.5301]: Process exited with status 0
2015-02-06T10:41:23.148562+00:00 heroku[run.5301]: State changed from up to complete
2015-02-06T13:37:04.131811+00:00 heroku[api]: Starting process with command
cat Procfile by johnb@heroku.com
2015-02-06T13:37:08.374192+00:00 heroku[run.3797]: Starting process with command
cat Procfile
2015-02-06T13:37:08.338415+00:00 heroku[run.3797]: Awaiting client
2015-02-06T13:37:08.560954+00:00 heroku[run.3797]: State changed from starting to up
2015-02-06T13:37:10.089507+00:00 heroku[run.3797]: Process exited with status 0
2015-02-06T13:37:10.113779+00:00 heroku[run.3797]: State changed from up to complete
2015-02-06T23:48:45.731958+00:00 heroku[api]: Deploy 6b11519 by kelvintgx@yahoo.com
2015-02-06T23:48:45.731958+00:00 heroku[api]: Release v8 created by kelvintgx@yahoo.com
2015-02-07T00:09:59.480138+00:00 heroku[api]: Release v9 created by kelvintgx@yahoo.com
2015-02-07T00:09:59.480138+00:00 heroku[api]: Deploy 6b11519 by kelvintgx@yahoo.com
2015-02-07T00:10:48.844680+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=7d1f4f4f-ef77-463c-a7ea-b8f324a659e7 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:10:50.372417+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=mighty-falls-2323.herokuapp.com request_id=cb478ca0-26db-4190-a352-73fac8e593bf fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:11:20.708121+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=257aa4ce-fcc5-478a-866e-16b5e06e6b28 fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-07T00:25:01.892151+00:00 heroku[api]: Release v10 created by kelvintgx@yahoo.com
2015-02-07T00:25:01.892151+00:00 heroku[api]: Deploy f656bf6 by kelvintgx@yahoo.com
2015-02-07T00:25:15.504015+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=ef792387-7275-473a-94a4-fd6d79193606 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:25:16.299068+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=mighty-falls-2323.herokuapp.com request_id=4bc9fe23-ef1c-4558-8dbc-e7a076184251 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:26:58.704016+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=2d0d428b-6e82-4fba-8bca-62b165dc9a8a fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:26:59.276275+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=56f32a41-ca5d-4177-af86-b5be5122e1a0 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:26:59.401230+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=3c74db5e-a184-43c6-8509-6d2652f98ad5 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:26:59.759710+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=ddb0c3bf-d037-4e88-91d0-527c3bdc5294 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:27:00.002293+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=b8213dc4-68f9-4506-9df3-8f8d9d84c17e fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:27:00.200540+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=4c3972ce-cf8d-455a-9642-fb7ab27614ab fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T00:27:31.036773+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=7d8cd1cf-047c-4f31-a77a-67d2fd407f3e fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-07T00:38:10.241481+00:00 heroku[api]: Deploy bce1b94 by kelvintgx@yahoo.com
2015-02-07T00:38:10.241481+00:00 heroku[api]: Release v11 created by kelvintgx@yahoo.com
2015-02-07T00:47:15.189446+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=d1e0f728-f37d-4bbc-934d-710a1bc6c038 fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-07T00:47:16.032290+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=mighty-falls-2323.herokuapp.com request_id=922e5bee-44c7-4175-b04a-c678ea892c49 fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-07T05:39:16.650160+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=20cda673-a9d5-4235-8c56-7d4ade42d3af fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-07T05:42:18.957812+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/test" host=mighty-falls-2323.herokuapp.com request_id=21b650da-b678-4e0f-b25c-07ce57dade4a fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-07T05:42:30.441817+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=736b31a0-54bd-426e-b139-82e9e3b59cfb fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-07T05:43:17.115422+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=cf5fc45d-7de3-4ceb-9ddb-e0359e9bee7e fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T05:43:28.889811+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=c28de66f-47fc-43e2-ba31-2cc9f75b60e7 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T05:45:00.848077+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/equations" host=mighty-falls-2323.herokuapp.com request_id=fa17ce1f-3fdf-4d6f-93af-00b4182f39d8 fwd="223.66.226.41" dyno= connect= service= status=503 bytes=
2015-02-07T08:27:44.307547+00:00 heroku[api]: Deploy 83dff7d by kelvintgx@yahoo.com
2015-02-07T08:27:44.307703+00:00 heroku[api]: Release v12 created by kelvintgx@yahoo.com
2015-02-07T08:28:22.236893+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=f42d825a-11ab-429b-8f37-cf1c2e2fa891 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T08:28:38.028373+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/test" host=mighty-falls-2323.herokuapp.com request_id=04e4cf42-ef58-44a4-92d7-5a62598260d7 fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T08:29:15.618833+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=mighty-falls-2323.herokuapp.com request_id=869ae9c3-4132-43d6-b84b-f8a4ea47375f fwd="223.66.227.40" dyno= connect= service= status=503 bytes=
2015-02-07T08:30:25.316324+00:00 heroku[api]: Deploy 83dff7d by kelvintgx@yahoo.com
2015-02-07T08:30:25.316324+00:00 heroku[api]: Release v13 created by kelvintgx@yahoo.com
我也尝试过heroku ps:scale web = 1命令:
Scaling dynos... failed
! No such process type web defined in Procfile.
python代码(在名为index.py的文件中):
from flask import Flask, make_response, request, json
import json
app = Flask(__name__)
@app.route('/test', methods = ['POST'])
def test():
resultJson = json.dumps(request.get_json())
response = app.response_class(resultJson, mimetype = 'application/json')
return response
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0')
Procfile:
web:gunicorn app:app
(我已遵循dirn的建议将Procfile内容更改为web:gunicorn index:app,但错误仍在此处。)
requirements.txt:
Flask>=0.9
Jinja2>=2.7.2
Werkzeug>=0.9.4
gunicorn>=18.0
由于我是这些东西的新手,所以我只是复制并粘贴其他人的Procfile和requirements.txt。
所有文件都在一个目录中。
在本地环境中,我只需要打开终端,然后运行命令:python~ / index.py,终端显示:
* Running on http://0.0.0.0:5000/
* Restarting with reloader
然后一切都按原样运作。从客户端应用程序,我可以使用一些json数据发布到url:http://0.0.0.0:5000/test,客户端应用程序将收到相同的json数据。
我不知道如何修复它。我只想在服务器中运行此脚本,脚本可以响应来自Internet的客户端应用程序请求。
答案 0 :(得分:1)
问题在于您的Procfile
。
web:gunicorn app:app
这告诉gunicorn运行名为app
的WSGI应用程序,该应用程序可以在名为app
的模块或包中找到。但是,您的模块名为index
。
您可以将index.py
重命名为app.py
或将Procfile
的内容更改为
web:gunicorn index:app