def html_override_tool():
 apiopts = cherrypy.config['apiopts']
 request = cherrypy.request
 url_blacklist = (apiopts.get('app_path', '/app'), apiopts.get('static_path', '/static'))
 if ('app' not in cherrypy.config['apiopts']):
  return
 if request.path_info.startswith(url_blacklist):
  return
 if (request.headers.get('Accept') == '*/*'):
  return
 try:
  wants_html = cherrypy.lib.cptools.accept('text/html')
 except cherrypy.HTTPError:
  return
 else:
  if (wants_html != 'text/html'):
   return
 raise cherrypy.InternalRedirect(apiopts.get('app_path', '/app'))

def html_override_tool ( ) : apiopts = cherrypy . config [ 'apiopts' ] request = cherrypy . request url_blacklist = ( apiopts . get ( 'app_path' , '/app' ) , apiopts . get ( 'static_path' , '/static' ) ) if ( 'app' not in cherrypy . config [ 'apiopts' ] ) : return if request . path_info . startswith ( url_blacklist ) : return if ( request . headers . get ( 'Accept' ) == '*/*' ) : return try : wants_html = cherrypy . lib . cptools . accept ( 'text/html' ) except cherrypy . HTTPError : return else : if ( wants_html != 'text/html' ) : return raise cherrypy . InternalRedirect ( apiopts . get ( 'app_path' , '/app' ) )
bypass the normal handler and serve html for all urls the app_path setting must be non-empty and the request must ask for text/html in the accept header .