我无法在Heroku上部署Python Flask。
以下是日志文件
的内容from app import app
File "/app/app/__init__.py", line 1, in <module>
ImportError: No module named flask
Traceback (most recent call last):
from flask import Flask
File "RunFlask.py", line 2, in <module>
State changed from starting to crashed
Starting process with command `python RunFlask.py`
Process exited with status 1 Contents of RunFlask.py
内容
$>cat __init__.py
from flask import Flask
app = Flask(__name__)
from app import views
$>cat RunFlask.py
import os
from app import app
port = int(os.environ.get('PORT', 5000))
app.run(debug = True)
print "starting flask server hostname:% port:%" % (host, port)
app.run(host='0.0.0.0', port=port)
目录结构
projectdir
- RunFlask.py
- app
--- __init__.py
--- views.py
- requirements.txt #Flask==0.10.1
答案 0 :(得分:2)
我假设您已经在Heroku上关注了getting started文档,并且您拥有一个与一个Heroku应用程序对应的本地存储库。根据您的目录结构,您会错过项目根目录中的 Procfile 。创建一个名为 Procfile 的文件,并将其添加到您的heroku应用程序中:
在您的项目目录中:
echo "web: python RunFlask.py" > Procfile
git add Procfile
git commit -m "adding ProcFile"
git push heroku master
heroku ps:scale web=1
heroku open