[英]Where to put the custom error page on Google App Engine
I would like to add a custom error page on my GAE service. 我想在我的GAE服务上添加一个自定义错误页面。
From the document , it doesn't mention where to put the error page. 在文档中 ,它没有提到将错误页面放在何处。
Here is my app.yaml
file: 这是我的
app.yaml
文件:
handlers:
- url: /static
static_dir: static
- url: .*
script: mega_jav.wsgi.application
error_handlers:
- file: error_default.html
- error_code: over_quota
file: error_over_quota.html
And I put my both error_default.html
and error_over_quota.html
in my templates folder. 然后将我的
error_default.html
和error_over_quota.html
放在我的模板文件夹中。
It doesn't work. 没用
Where should I put the error page into? 我应该在哪里放置错误页面? or can I modify the
app.yaml
file to make it works? 还是可以修改
app.yaml
文件使其工作?
Thank you very much. 非常感谢你。
I suggest you read the docs https://cloud.google.com/appengine/docs/python/config/appconfig?hl=en#Python_app_yaml_Custom_error_responses 我建议您阅读文档https://cloud.google.com/appengine/docs/python/config/appconfig?hl=zh-CN#Python_app_yaml_Custom_error_responses
It's pretty clear, the error handler referers to a file but not a static resource (in fact there is an explicit warning to not make the file overlap with the static handlers (I raised the issue with the docs in 2010 as it didn't note this fact, causing deployment problems - https://code.google.com/p/googleappengine/issues/detail?id=3759 ) 很明显,错误处理程序引用的是文件,而不是静态资源(实际上有明确警告,不要使文件与静态处理程序重叠(我在2010年提出了文档问题,因为它没有指出这个事实会导致部署问题-https://code.google.com/p/googleappengine/issues/detail?id=3759 )
Warning: Make sure that the path to the error response file does not overlap with static file handler paths.
警告:确保错误响应文件的路径与静态文件处理程序路径不重叠。
The page for the error handler is deployed in your code base. 错误处理程序页面已部署在您的代码库中。
And it has nothing to do with templates. 它与模板无关。 Though it's path could be in your templates.
虽然它的路径可能在您的模板中。 However its is purely static html/text that is served if there is an uncaught error, putting it in your templates could be a source of confusion as it's not a template.
但是,它是纯静态的html / text,如果出现未捕获的错误,则会将其投放,将其放入模板中可能会引起混乱,因为它不是模板。
The simplest place in is the root of your project. 最简单的位置是项目的根目录。 The file directive is a relative path not a handler
file指令是相对路径而不是处理程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.