python - How can I get consistent results for my error messages? -


i have following little script running standalone app based on cherrypy 3.2.2 (alright, it's condensed version demonstrate i'm trying correct):

import cherrypy cherrypy import _cperror  class myapp:   def __init__(self, **kwargs):     if ('recursive' in kwargs) , kwargs['recursive']:       return     cherrypy.tree.mount(myapp(recursive=true), '/cgi-bin', {})    def error_page(status, message, traceback, version):     error_template = """\ <html><head><title>%s</title></head> <body><h1>%s</h1><p>%s</p></body> </html>"""     return error_template % (status, status, message)    @cherrypy.expose   def script_name(self, **kwargs):     return str(kwargs)    favicon_ico = none   _cp_config = {'error_page.404' : error_page}  if __name__ == '__main__':   cherrypy.quickstart(       myapp(),       config = {         'global':{           'server.socket_host':'0.0.0.0',           'server.socket_port':8080,           }}) 

when fetch url underneath /cgi-bin or anywhere, expected:

404 not found

the path '/' not found.

however, when fetch passes "path_info" such /cgi-bin/script_name/foobar get:

404 not found

nothing matches given uri

how can ensure in latter case same error message (only variable being actual path mentioned in message) in former, while still being able serve content under uri /cgi-bin/script_name?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -