| Name | Size | Mode | Actions |
|---|---|---|---|
| __pycache__/ | - | 0755 | rm |
| custom_error.html | 404 | 0644 | editdlrm |
| pdf_file.pdf | 85698 | 0644 | editdlrm |
| README.rst | 617 | 0644 | editdlrm |
| tut01_helloworld.py | 1015 | 0644 | editdlrm |
| tut02_expose_methods.py | 801 | 0644 | editdlrm |
| tut03_get_and_post.py | 1587 | 0644 | editdlrm |
| tut04_complex_site.py | 2948 | 0644 | editdlrm |
| tut05_derived_objects.py | 2141 | 0644 | editdlrm |
| tut06_default_method.py | 2264 | 0644 | editdlrm |
| tut07_sessions.py | 1228 | 0644 | editdlrm |
| tut08_generators_and_yield.py | 1288 | 0644 | editdlrm |
| tut09_files.py | 3463 | 0644 | editdlrm |
| tut10_http_errors.py | 2706 | 0644 | editdlrm |
| tutorial.conf | 96 | 0644 | editdlrm |
| __init__.py | 85 | 0644 | editdlrm |
/opt/imh-python/lib/python3.9/site-packages/cherrypy/tutorial/tut10_http_errors.py (2706B)
Toggle tracebacks %s
Use a custom error page from a file.
These errors are explicitly raised by the application:
""" % trace @cherrypy.expose def toggleTracebacks(self): # simple function to toggle tracebacks on and off tracebacks = cherrypy.request.show_tracebacks cherrypy.config.update({'request.show_tracebacks': not tracebacks}) # redirect back to the index raise cherrypy.HTTPRedirect('/') @cherrypy.expose def error(self, code): # raise an error based on the get query raise cherrypy.HTTPError(status=code) @cherrypy.expose def messageArg(self): message = ("If you construct an HTTPError with a 'message' " 'argument, it wil be placed on the error page ' '(underneath the status line by default).') raise cherrypy.HTTPError(500, message=message) tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf') if __name__ == '__main__': # CherryPy always starts with app.root when trying to map request URIs # to objects, so we need to mount a request handler root. A request # to '/' will be mapped to HelloWorld().index(). cherrypy.quickstart(HTTPErrorDemo(), config=tutconf)