是否可以重定向到 404 和 500 页面而不是构建自定义响应?我试过了-
class NotFoundPageHandler(webapp.RequestHandler):
def get(self):
#if 400
self.redirect('error/notfound.html')
#if 500 how to check
def main():
application = webapp.WSGIApplication(
[
('/', MainPage),
('/index.html', MainPage),
('.*', NotFoundPageHandler)
], debug=True)
但它不起作用。
请您参考如下方法:
您不想重定向。您想要的是自定义错误页面。
http://code.google.com/appengine/docs/python/config/appconfig.html#Custom_Error_Responses
error_handlers:
- file: default_error.html
- error_code: over_quota
file: over_quota.html
- error_code: 404 或 - error_code: 500 应该也可以。仔细阅读该链接,听起来您必须小心那些文件不在静态文件目录中。
