拔掉我的头发!我正在尝试将Python FLask应用程序部署到AWS Elastic Beanstalk,我收到错误
目标WSGI脚本'/opt/python/current/app/application.py'不包含WSGI应用程序'application'
网页刚刚返回500服务器错误
我的application.py的内容如下:
#!/usr/bin/env python3
import connexion
if __name__ == '__main__':
application = connexion.App(__name__, specification_dir='./swagger/')
application.add_api('swagger.yaml', arguments={'title': 'This is a basic API fascade to theprotptype development robot. The API front-ends the communication with an MQTT pub/sub topic, which uses the Amazon Web Services IoT service.'})
application.run()
在本地运行正常,但在上传到AWS时效果不佳。我已将名称从app.py更改为application.py,并将app =更改为application =但没有更改
不知道下一步该去哪了:(
答案 0 :(得分:0)
尝试在if __name__ == '__main__'
之后移动application=...
行,因为启动器可以导入您的脚本而不是执行它。在这种情况下,__name__
不会被定义为__main__
。有关更好的示例,请参阅此page。
application = connexion.App(__name__, specification_dir='./swagger/')
application.add_api('swagger.yaml', arguments={'title': 'This is a basic API fascade to theprotptype development robot. The API front-ends the communication with an MQTT pub/sub topic, which uses the Amazon Web Services IoT service.'})
if __name__ == '__main__':
application.run()