我有一个Flask应用程序,用Cloud9 IDE编写。我在本地运行它:终端中的“python manage.py runserver”。 这然后触发:Python,Flask:Heroku无法打开(并运行)应用程序
manager.add_command('runserver', Server(
use_debugger = True,
use_reloader = True,
host = os.getenv('IP', '0.0.0.0'),
port = int(os.getenv('PORT', 5000))
)
)
这段代码位于manage.py文件。
现在我想用Heroku运行它。我完全按照他们的教程。我只是不知道我的Procfile应该是什么。我写的,像这样:
web: gunicorn manage:runserver
推混帐等一切似乎很好地工作。 当我键入: “Heroku的PS:衡量Web = 1”,我在终端得到这样的:
Scaling dynos... done, now running web at 1:Free.
当我键入 “Heroku的开放”,我得到这个错误:
Opening fierce-spire-3069... xprop: unable to open display ''
xprop: unable to open display ''
/usr/bin/xdg-open: 461: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 461: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 461: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 461: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'https://fierce-spire-3069.herokuapp.com/'
done
所以,我的应用程序无法打开。 当我用Heroku网站打开它时,出现一条错误消息。这是我在原木中发现的:
2015-12-29T20:15:06.399443+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fierce-spire-3069.herokuapp.com request_id=c5d76e45-5d56-45f4-a2bc-75bd7fc08b7f fwd="81.82.128.183" dyno= connect= service= status=503 bytes=
我在做什么错?
编辑
我改变了我的个人资料如下:
web: python manage.py runserver "0.0.0.0:5000"
在Heroku的日志中的上述错误消息已不存在,但有一个新问题:
2015-12-29T21:30:37.938957+00:00 app[web.1]: from tsb import app
2015-12-29T21:30:37.938955+00:00 app[web.1]: File "manage.py", line 7, in <module>
2015-12-29T21:30:37.939002+00:00 app[web.1]: ImportError: No module named tsb
这是指manage.py代码的这一部分:
from tsb import app
“tsb”是存储我所有项目文件的文件夹,它是项目文件夹。为什么不能导入?
不要在生产中使用内置的开发服务器,尤其是启用了调试器的情况下。 – davidism
你是什么意思?我不知道该怎么做ImortError。 – Vincent
我的意思是不要在生产中使用它,它既不安全也不高效。我没有评论导入错误。 – davidism