[英]Problem with accessing static files when deploying Django API using Google App Engine
I have schema.yml
documentation in the static folder in my project and during development everything seems to be working properly however after deployment to the App Engine
I get the error Not Found /static/schema.yml
.我在项目的 static 文件夹中有
schema.yml
文档,在开发过程中一切似乎都正常工作,但是在部署到App Engine
后我收到错误Not Found /static/schema.yml
。 My configuration looks in the way shown below.我的配置如下所示。 Do you have any ideas what can be the cause of the problem?
你有什么想法可能是问题的原因吗?
settings.py:设置.py:
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
STATIC_URL = '/static/'
app.yaml: app.yaml:
runtime: custom
env: flex
entrypoint: gunicorn -b :$PORT mysite.wsgi
service: mysite-service
handlers:
- url: /static/
static_dir: static
Google App Engine Flex for custom environments ignores the handlers section .用于自定义环境的 Google App Engine Flex 会忽略处理程序部分。 There are no issues if you add this section to your “app.yaml” but are not used by the environment.
如果您将此部分添加到“app.yaml”但环境不使用,则没有问题。 The handlers section is for Google App Engine Standard .
handlers 部分适用于Google App Engine Standard 。 So, that is the reason why in the App Engine Standard environment works but not in App Engine flex.
因此,这就是为什么在 App Engine 标准环境中有效但在 App Engine flex 中无效的原因。 The only language that supports handlers is java and you can find documentation that says that it is possible to do it.
唯一支持处理程序的语言是java ,您可以找到说明可以这样做的文档。
However, in order to serve static files, you can take a look at this doc where it includes the necessary steps to configure static files in App Engine Flex.但是,为了提供 static 文件,您可以查看此文档,其中包含在 App Engine Flex 中配置 static 文件的必要步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.