【发布时间】:2020-05-24 15:16:10
【问题描述】:
我正在学习 Google Cloud 的各种教程,尝试将我的第一个 Python Flask 应用程序部署到 App Engine。在 YouTube 上观看 Corey Schafer 的教程后,我将我的应用程序组织为一个包而不是模块:“Python Flask 教程:全功能 Web 应用第 5 部分 - 包结构”
所以现在,在我的工作目录中,我有一个这样的结构:
1. Project folder
1.1 myapp folder
1.1.1 __pycache__
1.1.2 static folder
1.1.3 __init__.py
1.1.4 app.yaml
1.1.5 requirements.txt
1.1.6 something_else.py
1.2 run.py
我的run.py 文件有以下代码:
from myapp import app
if __name__ == '__main__':
app.run(debug=True)
我的app.yaml 文件如下所示:
runtime: python37
handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /static
static_dir: static
# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
script: auto
现在我不知道如何设置我的 app.yaml 文件来指定入口点,以及在我将应用部署到 App Engine 时如何运行它。在我首先将cd 放入myapp 文件夹之后,我目前正在通过Google Cloud SDK 运行gcloud app deploy 命令?
控制台中的部署阶段进展顺利,但是当我检查应用程序的浏览链接时,我遇到了 502 Bad Gateway 错误(正如我所预料的那样)。
在本地一切正常,但部署对我来说不是太简单,因为我的应用程序的结构类似于包。非常感谢任何帮助。
【问题讨论】:
标签: python google-app-engine flask google-cloud-platform