Skip to content

Instantly share code, notes, and snippets.

@ktuite
Created December 5, 2012 23:42
Show Gist options
  • Save ktuite/4220561 to your computer and use it in GitHub Desktop.
Save ktuite/4220561 to your computer and use it in GitHub Desktop.
A snippet of a twisted server (python) that returns a crossdomain xml file
class RootResource(Resource):
def __init__(self):
Resource.__init__(self)
self.putChild('heartbeat', HeartbeatResource())
self.putChild('launch', LaunchResource())
self.putChild('get_port', GetPortResource())
self.putChild('crossdomain.xml', Grahh())
self.putChild('style.css', static.File("style.css"))
self.putChild('jquery.min.js', static.File("jquery.min.js"))
self.putChild('sketchup.js', static.File("sketchup.js"))
self.putChild('lewis-hall', InstanceResource("lewis-hall"))
self.putChild('uw-campus', InstanceResource("uw-campus"))
class Grahh(Resource):
def __init__(self):
Resource.__init__(self)
def render_GET(self, request):
s = "<?xml version=\"1.0\"?>\n<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\n<cross-domain-policy>\n\t<allow-access-from domain=\"*\" to-ports=\"*\" secure=\"false\"/>\n</cross-domain-policy>"
return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment