""" Show verbose server/client information. From boodebr.appspot.com. May be freely used and modified for any purpose. """ import cherrypy import wsgiref.handlers import sys, os from cherrypy.lib.static import serve_file def unknown(): return "Unknown" def makeinfo(args, kwargs): h = '' h += '

Request info

' h += '' # headers['Remote-Addr'] doesn't work in some environments h += '' % cherrypy.request.remote.ip h += '' % cherrypy.request.remote.port h += '' % cherrypy.request.headers['User-Agent'] h += '' % cherrypy.request.request_line h += '' % str(args) h += '' % str(kwargs) h += '
Remote IP%s
Remote port%s
Browser%s
Request%s
args%s
kwargs%s
' h += '

Headers (cherrypy.request.headers)

' h += '' # use header_list instead of headers so that I can see any duplicate keys for k,v in cherrypy.request.header_list: h += '' % (k,v) h += '
%s%s
' h += '

cherrypy.request.config

' h += '' for k,v in cherrypy.request.config.items(): h += '' % (k,v) h += '
%s%s
' h += '

WSGI environment (cherrypy.request.wsgi_environ)

' h += '' for k,v in cherrypy.request.wsgi_environ.items(): h += '' % (k,v) h += '
%s%s
' h += '

CherryPy Server (cherrypy.server)

' h += '' for k,v in cherrypy.server.__dict__.items(): h += '' % (k,v) h += '
%s%s
' h += '

Host environment

' h += '' h += '' % sys.version h += '' % cherrypy.__version__ h += '' % (' '.join(sys.argv)) h += '' % os.getcwd() h += '' % (os.name,sys.platform) f = getattr(os, 'uname', unknown) h += '' % str(f()) h += '
Python version%s
CherryPy version%s
Server command%s
os.getcwd()%s
OS/Platform%s/%s
os.uname()%s
' h += '

Environment variables (os.environ)

' h += '' for k,v in os.environ.items(): h += '' % (k,v) h += '
%s%s
' h += '' return h class Root: def index(self): return makeinfo((),{}) index.exposed = True def default(self, *args, **kwargs): return makeinfo(args, kwargs) default.exposed = True def source(self): buf = open(os.path.abspath(__file__)).read() cherrypy.response.headers['Content-Type'] = 'text/plain' return buf source.exposed = True #--------------------------------------------------------------------------- # Start the server under Google AppEngine #--------------------------------------------------------------------------- # IMPORTANT! Make sure to mount at "/infodump" to match my actual URL. app = cherrypy.tree.mount(Root(), "/infodump") wsgiref.handlers.CGIHandler().run(app)