2015-02-06 51 views
0

我是python和flask的新手。 燒瓶的文件說你可以將你的應用程序部署到heroku以供公衆訪問。所以我轉向heroku網站。我一步步地按照入門指南進行操作。我成功部署了應用程序,但是當我使用https://mighty-falls-2223.heroku.com/這樣的給定網址進行測試時,它說有錯誤。heroku不能用我的python腳本

的錯誤信息是:

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上記錄命令:

2015-02-06T05:05:23.598482+00:00 heroku[api]: Release v2 created by [email protected] 2015-02-06T05:05:23.598482+00:00 heroku[api]: Enable Logplex by [email protected] 2015-02-06T05:43:45.975680+00:00 heroku[api]: Deploy 6c41484 by [email protected] 2015-02-06T05:43:45.975680+00:00 heroku[api]: Release v3 created by [email protected] 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 [email protected] 2015-02-06T05:47:57.279689+00:00 heroku[api]: Release v4 created by [email protected] 2015-02-06T06:02:22.868450+00:00 heroku[api]: Release v5 created by [email protected] 2015-02-06T06:02:22.868450+00:00 heroku[api]: Deploy 38003ed by [email protected] 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 [email protected] 2015-02-06T06:08:41.991908+00:00 heroku[api]: Release v6 created by [email protected] 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 [email protected] 2015-02-06T08:03:09.470102+00:00 heroku[api]: Deploy 9d0211e by [email protected] 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假& &自動診斷正在運行的Heroku BY SUPPORT;貓Procfile by [email protected] 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 SUPPORT運行;貓Procfile 2015-02-06T10:25:48.553909+00:00 heroku[api]: Starting process with command false & &自動診斷由HEROKU SUPPORT運行; cat requirements.txt by [email protected] 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 SUPPORT運行;貓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 [email protected] 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貓Procfile by [email protected] 2015-02-06T13:37:08.374192+00:00 heroku[run.3797]: Starting process with command貓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 [email protected] 2015-02-06T23:48:45.731958+00:00 heroku[api]: Release v8 created by [email protected] 2015-02-07T00:09:59.480138+00:00 heroku[api]: Release v9 created by [email protected] 2015-02-07T00:09:59.480138+00:00 heroku[api]: Deploy 6b11519 by [email protected] 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 [email protected] 2015-02-07T00:25:01.892151+00:00 heroku[api]: Deploy f656bf6 by [email protected] 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.4: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 [email protected] 2015-02-07T00:38:10.241481+00:00 heroku[api]: Release v11 created by [email protected] 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 [email protected] 2015-02-07T08:27:44.307703+00:00 heroku[api]: Release v12 created by [email protected] 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 [email protected] 2015-02-07T08:30:25.316324+00:00 heroku[api]: Release v13 created by [email protected]

我還試圖heroku上PS:規模幅= 1級的命令:

Scaling dynos... failed ! No such process type web defined in Procfile.

的Python代碼(在指定的索引文件中。 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內容網站:gunicorn指數:應用程序,但錯誤仍在這裏)

的requirements.txt:

Flask>=0.9 
Jinja2>=2.7.2 
Werkzeug>=0.9.4 
gunicorn>=18.0 

由於我這些新東西,所以我只是複製和粘貼其他人的Procfile和requirements.txt。

所有的文件都在一個目錄中。

在當地的環境,我只需要打開終端,然後運行命令:蟒蛇〜/ index.py,終端顯示:

* Running on http://0.0.0.0:5000/ 
* Restarting with reloader 

然後一切工作,因爲它是。從客戶端應用程序,我可以發佈到URL:http://0.0.0.0:5000/test與一些JSON數據,客戶端應用程序將收到相同的JSON數據。

我不知道如何解決它。我只想在服務器上運行此腳本,腳本可以響應客戶端應用程序的來自Internet的請求。

+0

我不認爲這是有關你的問題,但你不應該在生產系統上運行'調試= TRUE; – 2015-02-06 12:06:05

回答

1

問題出在您的Procfile

web:gunicorn app:app 

這告訴gunicorn運行名爲app的WSGI應用程序,可以命名app模塊或包中找到。但是,您的模塊名爲index

您可以重命名index.pyapp.py或更改Procfile的內容

web:gunicorn index:app 
+0

我已經用你的建議編輯了Procfile,但是錯誤仍然存​​在。 我應該編輯'app.run(host ='0.0.0.0')'還是可以將'index:app'更改爲'app:index'? – CokileCeoi 2015-02-07 00:30:31

+0

什麼是錯誤?你沒有把它包含在你的問題中。 – dirn 2015-02-07 00:32:52

+0

我已經通過將Procfile的內容更改爲'web:gunicorn index:app'來修復它。'web:'和'gunicorn'之間有一個空格 – CokileCeoi 2015-02-08 04:44:27