2

我的 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'
4

1 回答 1

0

Apparently this is the right format of the application.py:

application = config_app(os.environ, __name__)

if __name__ == "__main__":
     application.run(threaded=True)
于 2018-07-23T13:39:39.333 回答