Saturday, 15 Dec. 2012

Cross-Origin Resource Sharing (CORS) is a specification that enables truly open access across domain-boundaries.
The Enable-Cors project collects various solutions for different platforms and adapted my solution for static hosted content on the Google Appengine.

The solution is listed on the Resources page under "Libraries for implementing CORS" where you can find the link to the complete library to deploy static content to the Appengine and fully control "Cross-Origin Resource Sharing".

A preview of

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import os

class MainPage(webapp.RequestHandler):
  def get(self):

class CORSEnabledHandler(webapp.RequestHandler):
	def get(self, path):
		path = os.path.join(os.path.dirname(__file__), 'static', path.split('/')[-1])
		self.response.headers.add_header("Access-Control-Allow-Origin", "*")
# any type
		self.response.headers['Content-Type'] = '*.*'
		self.response.out.write(open(path, 'rb').read())

application = webapp.WSGIApplication(

        [('/(.+)$', CORSEnabledHandler),
        ('/', MainPage)], 

def main():

if __name__ == "__main__":

The complete library with source files can be found on my Github: GaeCors