我正在开发一个烧瓶应用程序,其结构与基于http://code.tutsplus.com/tutorials/an-introduction-to-pythons-flask-framework--net-28822的屏幕截图相同。为了让它在本地工作,我一直在运行routes.py文件:
$ python C:/envs/r2/mini/intro_to_flask/routes.py
C:\envs\virtalenvs\flask_mini\lib\site-packages\flask_sqlalchemy\__init__.py:800: Use
rWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabl
ed by default in the future. Set it to True to suppress this warning.
warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be
disabled by default in the future. Set it to True to suppress this warning.')
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
哪个正常。我现在正试图在https://www.udacity.com/wiki/ud330/deploy之后使用gunicorn在heroku上部署。按照说明,我的requirements.txt包含:
$ pip Freeze
Flask==0.10.1
Flask-Mail==0.9.1
Flask-SQLAlchemy==2.1
Flask-WTF==0.12
Jinja2==2.8
MarkupSafe==0.23
SQLAlchemy==1.0.11
WTForms==2.1
Werkzeug==0.11.3
blinker==1.4
gunicorn==19.4.5
itsdangerous==0.24
routes.py:
from flask import render_template, request, flash, session, url_for, redirect
from forms import ContactForm, SignupForm, SigninForm
from flask.ext.mail import Message, Mail
from models import db, User
from flask import Flask
app = Flask(__name__)
....... code ........
app.run()
我不确定将什么放入我的Procfile中,我尝试过多种变体,包括:
web: gunicorn runserver:app
heroku日志显示:
←[36m2016-01-23T19:14:56.910512+00:00 app[web.1]:←[0m from intro_to_flask import
routes
←[36m2016-01-23T19:14:56.910513+00:00 app[web.1]:←[0m File "/app/intro_to_flask/rou
tes.py", line 123, in <module>
←[36m2016-01-23T19:14:56.910513+00:00 app[web.1]:←[0m app.run()
←[36m2016-01-23T19:14:56.910514+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/flask/app.py", line 772, in run
←[36m2016-01-23T19:14:56.910515+00:00 app[web.1]:←[0m run_simple(host, port, self
, **options)
←[36m2016-01-23T19:14:56.910515+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/werkzeug/serving.py", line 692, in run_simple
←[36m2016-01-23T19:14:56.910516+00:00 app[web.1]:←[0m inner()
←[36m2016-01-23T19:14:56.910516+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/werkzeug/serving.py", line 654, in inner
←[36m2016-01-23T19:14:56.910517+00:00 app[web.1]:←[0m fd=fd)
←[36m2016-01-23T19:14:56.910518+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/werkzeug/serving.py", line 548, in make_server
←[36m2016-01-23T19:14:56.910518+00:00 app[web.1]:←[0m passthrough_errors, ssl_con
text, fd=fd)
←[36m2016-01-23T19:14:56.910519+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/site-packages/werkzeug/serving.py", line 462, in __init__
←[36m2016-01-23T19:14:56.910523+00:00 app[web.1]:←[0m HTTPServer.__init__(self, (
host, int(port)), handler)
←[36m2016-01-23T19:14:56.910524+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/SocketServer.py", line 420, in __init__
←[36m2016-01-23T19:14:56.910525+00:00 app[web.1]:←[0m self.server_bind()
←[36m2016-01-23T19:14:56.910526+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/BaseHTTPServer.py", line 108, in server_bind
←[36m2016-01-23T19:14:56.910526+00:00 app[web.1]:←[0m SocketServer.TCPServer.serv
er_bind(self)
←[36m2016-01-23T19:14:56.910527+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/SocketServer.py", line 434, in server_bind
←[36m2016-01-23T19:14:56.910528+00:00 app[web.1]:←[0m self.socket.bind(self.serve
r_address)
←[36m2016-01-23T19:14:56.910529+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib
/python2.7/socket.py", line 228, in meth
←[36m2016-01-23T19:14:56.910529+00:00 app[web.1]:←[0m return getattr(self._sock,n
ame)(*args)
←[36m2016-01-23T19:14:56.910548+00:00 app[web.1]:←[0m error: [Errno 98] Address alrea
dy in use
←[36m2016-01-23T19:14:56.910686+00:00 app[web.1]:←[0m [2016-01-23 19:14:56 +0000] [10
] [INFO] Worker exiting (pid: 10)
←[36m2016-01-23T19:14:57.199826+00:00 heroku[web.1]:←[0m State changed from starting
to up
有人可以告诉我如何让它运行吗?