def cors_handler(*args, **kwargs):
 req_head = cherrypy.request.headers
 resp_head = cherrypy.response.headers
 ac_method = req_head.get('Access-Control-Request-Method', None)
 allowed_methods = ['GET', 'POST']
 allowed_headers = ['X-Auth-Token', 'Content-Type']
 if (ac_method and (ac_method in allowed_methods)):
  resp_head['Access-Control-Allow-Methods'] = ', '.join(allowed_methods)
  resp_head['Access-Control-Allow-Headers'] = ', '.join(allowed_headers)
  resp_head['Connection'] = 'keep-alive'
  resp_head['Access-Control-Max-Age'] = '1400'
 return {}

def cors_handler ( * args , ** kwargs ) : req_head = cherrypy . request . headers resp_head = cherrypy . response . headers ac_method = req_head . get ( 'Access-Control-Request-Method' , None ) allowed_methods = [ 'GET' , 'POST' ] allowed_headers = [ 'X-Auth-Token' , 'Content-Type' ] if ( ac_method and ( ac_method in allowed_methods ) ) : resp_head [ 'Access-Control-Allow-Methods' ] = ', ' . join ( allowed_methods ) resp_head [ 'Access-Control-Allow-Headers' ] = ', ' . join ( allowed_headers ) resp_head [ 'Connection' ] = 'keep-alive' resp_head [ 'Access-Control-Max-Age' ] = '1400' return { }
check a cors preflight request and return a valid response .