Mr *_*edi 9 python heroku flask flask-restless
我正在尝试使用Heroku部署Flask应用程序.这是简单的API.与工头一起工作很棒但是在heroku上启动时我得到错误(日志在下面).
这是我的应用程序代码(我知道它只是查看一个块,但我有问题将其拆分为文件):
import flask
import flask.ext.sqlalchemy
import flask.ext.restless
app = flask.Flask(__name__)
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://user:password@server/db'
db = flask.ext.sqlalchemy.SQLAlchemy(app)
from sqlalchemy import Column, Integer, String, ForeignKey,\
Date, DateTime, Boolean, Float
class fruits(db.Model):
__tablename__ = 'fruits'
id = Column(Integer, primary_key=True)
name = Column(String(50),nullable=False)
calories = Column(Integer, nullable=False)
amount = Column(Integer, nullable=False)
unit = Column(String(10),nullable=False)
url = Column(String(100),nullable=True)
@app.route('/')
def hello_world():
return 'Hello World!'
# Create the database tables.
db.create_all()
# Create the Flask-Restless API manager.
manager = flask.ext.restless.APIManager(app, flask_sqlalchemy_db=db)
# Create API endpoints, which will be available at /api/<tablename> by
# default. Allowed HTTP methods can be specified as well.
manager.create_api(fruits, methods=['GET', 'POST', 'DELETE'])
manager.create_api(tmp, methods=['GET', 'POST', 'DELETE'])
# start the flask loop
if __name__ == '__main__':
import os
port = int(os.environ.get('PORT', 33507))
app.run(host='0.0.0.0', port=port)
Run Code Online (Sandbox Code Playgroud)
这是heroku日志:
at=error code=H14 desc="No web processes running" method=GET path=/ host=blooming-taiga-1210.herokuapp.com fwd="188.33.19.82" dyno= connect= service= status=503 bytes=
Run Code Online (Sandbox Code Playgroud)
和我的Procfile:
web: python __init__.py
Run Code Online (Sandbox Code Playgroud)
Luk*_*raf 19
实际上是否有一个正在运行的dyno web
?看起来您可能忘记扩展您的网络动态:
在Procfile中添加这样的条目:
heroku ps:scale web=1
Run Code Online (Sandbox Code Playgroud)
您可以使用
heroku ps
Run Code Online (Sandbox Code Playgroud)
确认您的web
dyno正在运行.
归档时间: |
|
查看次数: |
6201 次 |
最近记录: |