Zappa不适用于Flask Blueprint

时间:2018-06-25 10:02:14

标签: python flask blueprint zappa

我有一个Flask应用,正在使用flask_restful和blueprint提供我的API。 使用Zappa部署我的应用程序后,Zappa给我以下错误:

Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code.

当我删除我的api时,zappa没有给我任何错误。 所以,我知道蓝图是有问题的。

我该如何解决这个问题?

(当然,我正在使用Python 3.6)

zappa_settings.py

{
"dev": {
"app_function": "main.app",
"aws_region": "us-east-1",
"profile_name": "default",
"project_name": "zap",
"runtime": "python3.6",
"s3_bucket": -MYBUCKETNAME-
}
}

main.py

from flask import Flask
from api.api import serendipity
from api.chat_api import chat
from database import db
# from mail import mail
# from admin.controller import admin

app = Flask(__name__, template_folder='admin/templates')
app.config.from_object('config')

app.register_blueprint(serendipity)
app.register_blueprint(chat, url_prefix='/chat')

with serendipity_app.app_context():
    db.init_app(app)
    db.create_all(app=app)
    mail.init_app(app)
    admin.init_app(app)

@app.route('/')
def index():
    return "{ message: 'Hello, world!' }", 200

# We only need this for local development.
if __name__ == '__main__':
    app.run(host='0.0.0.0')

环境

使用的Zappa版本:最新(0.46.1) 操作系统和Python版本:mac os High Sierra,10.13.5(17F77) 点冻结的输出:

aniso8601==3.0.2
argcomplete==1.9.3
arrow==0.12.1
base58==1.0.0
bcrypt==3.1.4
blinker==1.4
boto3==1.7.45
botocore==1.10.45
CacheControl==0.12.5
cachetools==2.1.0
certifi==2018.4.16
cffi==1.11.5
cfn-flip==1.0.3
chardet==3.0.4
click==6.7
docutils==0.14
durationpy==0.5
firebase-admin==2.11.0
Flask==1.0.2
Flask-Admin==1.5.1
Flask-Mail==0.9.1
Flask-RESTful==0.3.6
Flask-SQLAlchemy==2.3.2
future==0.16.0
gcloud==0.17.0
geographiclib==1.49
geopy==1.14.0
google-api-core==1.2.1
google-api-python-client==1.7.3
google-auth==1.5.0
google-auth-httplib2==0.0.3
google-cloud-core==0.28.1
google-cloud-firestore==0.29.0
google-cloud-storage==1.10.0
google-resumable-media==0.3.1
googleapis-common-protos==1.5.3
grpcio==1.12.1
hjson==3.0.1
httplib2==0.11.3
idna==2.7
itsdangerous==0.24
Jinja2==2.10
jmespath==0.9.3
jws==0.1.3
kappa==0.6.0
lambda-packages==0.20.0
MarkupSafe==1.0
msgpack==0.5.6
numpy==1.14.5
oauth2client==3.0.0
placebo==0.8.1
protobuf==3.6.0
pyasn1==0.4.3
pyasn1-modules==0.2.1
pycparser==2.18
pycryptodome==3.4.3
pyfcm==1.4.5
Pyrebase==3.0.27
python-dateutil==2.6.1
python-jwt==2.0.1
python-slugify==1.2.4
pytz==2018.4
PyYAML==3.12
requests==2.19.1
requests-toolbelt==0.7.0
rsa==3.4.2
s3transfer==0.1.13
six==1.11.0
SQLAlchemy==1.2.8
SQLAlchemy-Utils==0.33.3
toml==0.9.4
tqdm==4.19.1
troposphere==2.3.0
Unidecode==1.0.22
uritemplate==3.0.0
urllib3==1.23
Werkzeug==0.14.1
wsgi-request-logger==0.4.6
WTForms==2.2.1
zappa==0.46.1

1 个答案:

答案 0 :(得分:1)

解决了自己。 Zappa版本是问题所在。我将zappa和pip降级了,然后就可以了!