Zappa正确设置了"app_function"



我的Flask应用程序有以下设置:

├── app
│   ├── __init__.py
│   └── routes.py
├── application.py
└── zappa_settings.json

application.py:

import os
from app import config_app

if __name__ == "__main__":
application = config_app(os.environ, __name__)
application.run(threaded=True)

app/__init__.py:

from flask import Flask
def config_app(config, name=__name__):
app = Flask(__name__)
app.config.from_mapping(config)
...
return app

现在我正在尝试将zappa应用程序部署到AWS。当运行zappa init时,它会提示输入app_function,但我不完全确定该将其设置为什么

"app_function": "application.application"

它在最后返回一个502错误。

运行zappa tail:

Traceback (most recent call last):
File "/var/task/handler.py", line 567, in lambda_handler
return LambdaHandler.lambda_handler(event, context)
File "/var/task/handler.py", line 237, in lambda_handler
handler = cls()
File "/var/task/handler.py", line 132, in __init__
wsgi_app_function = getattr(self.app_module, self.settings.APP_FUNCTION)
AttributeError: module 'application' has no attribute 'application'

显然这是application.py:的正确格式

application = config_app(os.environ, __name__)
if __name__ == "__main__":
application.run(threaded=True)

相关内容

  • 没有找到相关文章

最新更新