使用 GCP 托管的 django 应用程序出现服务器错误
Server error on django app hosted using GCP
我的应用程序出现 500 服务器错误,我刚刚使用 google 云托管
https://exam-3d397.el.r.appspot.com/
我不确定我的 app.yaml 应该是什么样子 -
runtime: python39
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
# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
manual_scaling:
instances: 1
resources:
cpu: 2
memory_gb: 4
disk_size_gb: 10
我将此添加到我的 settings.py -
ALLOWED_HOSTS = ['.herokuapp.com', '127.0.0.1', '.r.appspot.com']
部署没有错误。我之前已经部署在 heroku
我的文件结构看起来像 structure
我还可以通过 https://exam-3d397.el.r.appspot.com/static/images/logo.png
查看我的静态文件
我是使用 google 云托管的新手,欢迎任何帮助。
我看到来自 App Engine 标准和灵活环境的混合 app.yaml 元素。删除“资源”元素,因为您似乎正在尝试使用标准环境并尝试。
另外,如果上面还是不行,给ALLOWED_HOSTS = ["*"]。
- 从您提供的 app.yaml 文件来看,您似乎混合了标准环境和灵活环境的配置。
- 请确定使用哪个环境,灵活配置参考this document for standard configuration and this document
- 另外,从 app.yaml 配置的处理程序部分来看,URI 路径似乎有一些错误。请按照 this link 了解如何在处理程序中提供正确的路径。
我的应用程序出现 500 服务器错误,我刚刚使用 google 云托管 https://exam-3d397.el.r.appspot.com/
我不确定我的 app.yaml 应该是什么样子 -
runtime: python39
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
# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
manual_scaling:
instances: 1
resources:
cpu: 2
memory_gb: 4
disk_size_gb: 10
我将此添加到我的 settings.py -
ALLOWED_HOSTS = ['.herokuapp.com', '127.0.0.1', '.r.appspot.com']
部署没有错误。我之前已经部署在 heroku
我的文件结构看起来像 structure
我还可以通过 https://exam-3d397.el.r.appspot.com/static/images/logo.png
查看我的静态文件我是使用 google 云托管的新手,欢迎任何帮助。
我看到来自 App Engine 标准和灵活环境的混合 app.yaml 元素。删除“资源”元素,因为您似乎正在尝试使用标准环境并尝试。
另外,如果上面还是不行,给ALLOWED_HOSTS = ["*"]。
- 从您提供的 app.yaml 文件来看,您似乎混合了标准环境和灵活环境的配置。
- 请确定使用哪个环境,灵活配置参考this document for standard configuration and this document
- 另外,从 app.yaml 配置的处理程序部分来看,URI 路径似乎有一些错误。请按照 this link 了解如何在处理程序中提供正确的路径。