使用Heroku和Django / Flask部署应用程序;在gunicorn的某个地方坠毁

时间:2016-08-21 05:32:05

标签: python django heroku

我正在尝试使用Heroku建立一个相对简单的Python Web应用程序。我试图将它设置为运行Flask和Django,但我得到了同样的,神秘的错误。

以下是代码:

from flask import Flask, render_template, request, redirect
...

app = Flask(__name__)

@app.route('/')
def main():
    return redirect('/index')

@app.route('/index')
def index():
    if request.method == 'GET':
        return render_template('index.html')
    ....

if __name__ == '__main__':
    app.run(port = 33507)

这里是procfile:

web: gunicorn app: app --preload

以下是错误消息:

> 2016-08-21T05:15:57.382095+00:00 heroku[slug-compiler]: Slug
> compilation started 2016-08-21T05:15:57.382104+00:00
> heroku[slug-compiler]: Slug compilation finished
> 2016-08-21T05:15:57.567071+00:00 heroku[web.1]: State changed from
> crashed to starting 2016-08-21T05:16:05.976837+00:00 heroku[web.1]:
> Starting process with command `gunicorn app: app --preload`
> 2016-08-21T05:16:11.732836+00:00 heroku[web.1]: Process exited with
> status 1 2016-08-21T05:16:11.534353+00:00 app[web.1]: Traceback (most
> recent call last): 2016-08-21T05:16:11.534365+00:00 app[web.1]:   File
> "/app/.heroku/miniconda/bin/gunicorn", line 11, in <module>
> 2016-08-21T05:16:11.534370+00:00 app[web.1]:     sys.exit(run())
> 2016-08-21T05:16:11.534371+00:00 app[web.1]:   File
> "/app/.heroku/miniconda/lib/python2.7/site-packages/gunicorn/app/wsg
> iapp.py", line 74, in run 2016-08-21T05:16:11.534397+00:00 app[web.1]:
> WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
> 2016-08-21T05:16:11.534400+00:00 app[web.1]:   File
> "/app/.heroku/miniconda/lib/python2.7/site-packages/gunicorn/app/bas
> e.py", line 192, in run 2016-08-21T05:16:11.534439+00:00 app[web.1]:  
> super(Application, self).run() 2016-08-21T05:16:11.534451+00:00
> app[web.1]:   File
> "/app/.heroku/miniconda/lib/python2.7/site-packages/gunicorn/app/bas
> e.py", line 72, in run 2016-08-21T05:16:11.534475+00:00 app[web.1]:   
> Arbiter(self).run() 2016-08-21T05:16:11.534488+00:00 app[web.1]:  
> File
> "/app/.heroku/miniconda/lib/python2.7/site-packages/gunicorn/arbiter
> .py", line 61, in __init__ 2016-08-21T05:16:11.534527+00:00
> app[web.1]:     self.setup(app) 2016-08-21T05:16:11.534528+00:00
> app[web.1]:   File
> "/app/.heroku/miniconda/lib/python2.7/site-packages/gunicorn/arbiter
> .py", line 120, in setup 2016-08-21T05:16:11.534566+00:00 app[web.1]: 
> self.app.wsgi() 2016-08-21T05:16:11.534567+00:00 app[web.1]:   File
> "/app/.heroku/miniconda/lib/python2.7/site-packages/gunicorn/app/bas
> e.py", line 67, in wsgi 2016-08-21T05:16:11.534568+00:00 app[web.1]:  
> self.callable = self.load() 2016-08-21T05:16:11.534570+00:00
> app[web.1]:   File
> "/app/.heroku/miniconda/lib/python2.7/site-packages/gunicorn/app/wsg
> iapp.py", line 65, in load 2016-08-21T05:16:11.534598+00:00
> app[web.1]:     return self.load_wsgiapp()
> 2016-08-21T05:16:11.534599+00:00 app[web.1]:   File
> "/app/.heroku/miniconda/lib/python2.7/site-packages/gunicorn/app/wsg
> iapp.py", line 52, in load_wsgiapp 2016-08-21T05:16:11.534624+00:00
> app[web.1]:     return util.import_app(self.app_uri)
> 2016-08-21T05:16:11.534718+00:00 app[web.1]:     app = eval(obj,
> mod.__dict__) 2016-08-21T05:16:11.534639+00:00 app[web.1]:   File
> "/app/.heroku/miniconda/lib/python2.7/site-packages/gunicorn/util.py
> ", line 368, in import_app 2016-08-21T05:16:11.534754+00:00
> app[web.1]:   File "<string>", line 0 2016-08-21T05:16:11.534755+00:00
> app[web.1]:     ^ 2016-08-21T05:16:11.534755+00:00 app[web.1]:
> 2016-08-21T05:16:11.534756+00:00 app[web.1]: SyntaxError: unexpected
> EOF while parsing 2016-08-21T05:16:11.745722+00:00 heroku[web.1]:
> State changed from starting to crashed
> 2016-08-21T05:16:12.857511+00:00 heroku[router]: at=error code=H10
> desc="App crashed" method=GET path="/" host=
> x.herokuapp.com request_id=4d61809c-4b63-448b-b2ed-87d3b24601fc
> fwd="24.7.75.211" dyno= connect= service= status=503 b ytes=
> 2016-08-21T05:16:13.340443+00:00 heroku[router]: at=error code=H10
> desc="App crashed" method=GET path="/favicon.ico" hos
> t=x.herokuapp.com
> request_id=9a4f00f2-c02e-4d60-9eb2-0ba69d211a6b fwd="24.7.75.211"
> dyno= connect= service= s tatus=503 bytes=

谢谢!

0 个答案:

没有答案