我有一个Web服务器,其中包含代码中设置的所有配置,但我希望能够处理所有页面404错误.我将如何在Python中执行此操作?
如果您想要更传统的4xx和5xx输出替换,请参阅http://www.cherrypy.org/wiki/ErrorsAndExceptions#AnticipatedHTTPresponses.
在根目录中创建一个默认处理程序.
class Root:
def index(self):
return "Hello!"
index.exposed = True
def default(self, attr='abc'):
return "Page not Found!"
default.exposed = True
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7205 次 |
| 最近记录: |