Skip to content

Instantly share code, notes, and snippets.

@victoroliv2
Created October 7, 2011 19:09
Show Gist options
  • Save victoroliv2/1271118 to your computer and use it in GitHub Desktop.
Save victoroliv2/1271118 to your computer and use it in GitHub Desktop.
web.py server which allow cross-site xmlhttprequest
import web
urls = (
'/(.*)', 'Service'
)
app = web.application(urls, globals())
class Service:
def GET(self, name):
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Credentials', 'true')
return {'message': GET OK!'}
def POST(self, name):
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Credentials', 'true')
data = web.data()
return {'message': "POST OK! %s" % data}
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment