【发布时间】:2020-12-11 14:42:53
【问题描述】:
在将非常简单的 Hello, World 类型的烧瓶应用程序部署到 AWS Elastic Beanstalk 时遇到问题。我正在使用 eb CLI 工具,安装在 Mac 上,带有 brew 和 python 3。下面的一些示例代码:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
@app.route('/<username>')
def hello_user(username):
return f'Hello, {username}!'
# run the app.
if __name__ == "__main__":
# Setting debug to True enables debug output. This line should be
# removed before deploying a production app.
app.debug = True
app.run(port=8000)
它按预期在本地运行,我可以通过 CLI 部署它,但是当我访问应用程序时,我得到一个 502 Bad Gateway。
我试过了:
- 使用控制台中的 URL 和
eb open访问应用程序。 - 在 URL 末尾指定端口 5000(默认烧瓶)和 8000。
- 使用
app.run()和app.run(port=8000)没有成功。
我查看了文档,但找不到修复方法。如果人们有任何他们认为会有所帮助的建议或链接,我们将不胜感激。
【问题讨论】:
标签: python amazon-web-services flask amazon-elastic-beanstalk