使用GCP托管的django应用程序出现服务器错误



我的应用程序上出现了500服务器错误,我刚刚使用谷歌云托管了该应用程序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

我把它添加到我的设置.py-

ALLOWED_HOSTS = ['.herokuapp.com', '127.0.0.1', '.r.appspot.com']

部署时没有错误。我早些时候已经部署在heroku 上

我的文件结构看起来像结构

此外,我还可以通过以下方式查看我的静态文件:https://exam-3d397.el.r.appspot.com/static/images/logo.png

我是谷歌云托管的初学者,任何帮助都将不胜感激。

我看到了来自app Engine Standard和Flexible环境的混合app.yaml元素。删除";资源";元素,因为您似乎正在尝试使用标准环境并尝试。

此外,如果以上仍然不起作用,则给出ALLOWED_HOSTS=["*"]。

  • 从您提供的app.yaml文件中,您似乎混合了标准和灵活环境的配置
  • 请确保使用哪种环境,并参考本文档了解标准配置,参考本文档查看灵活配置
  • 此外,从app.yaml配置中的handlers部分来看,URI路径似乎有一些错误。请点击此链接了解如何在处理程序中提供正确的路径

最新更新