python - How to cross-domain in cherrypy normal application? -


class helloworld:     @cherrypy.expose     def hello(self):         return "hello world!" 

cherrypy.quickstart(helloworld())

i cross-domain request: http://ip:port/hello unsuccessfully, , add decorator(which working in restful application) before method hello that:

def crossdomain(func):     def decorate(*args, **kwargs):         cherrypy.response.headers["access-control-allow-origin"] = "*"         cherrypy.response.headers["access-control-allow-methods"] = "get, post, head, put, delete"         allow_headers = ["cache-control", "x-proxy-authorization", "x-requested-with", "content-type"]         cherrypy.response.headers["access-control-allow-headers"] = ",".join(allow_headers)         return func(*args, **kwargs)     return decorate  class helloworld:     @cherrypy.expose     @crossdomain     def hello(self):         return "hello world!"  cherrypy.quickstart(helloworld()) 

the browser throw exception: options http://192.168.1.236:1987/hello 500 (internal server error)

because cherrypy can not find http method "options". how can make cherrypy dispatch options request automatically?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -