Skip to content

Instantly share code, notes, and snippets.

@hadrien
Last active August 29, 2015 13:57
Show Gist options
  • Save hadrien/9746283 to your computer and use it in GitHub Desktop.
Save hadrien/9746283 to your computer and use it in GitHub Desktop.
/crossdomain.xml with pyramid
from pyramid.path import AssetResolver
from pyramid.response import Response
from pyramid.view import view_config
@view_config(name="crossdomain.xml")
def crossdomain_view(request):
"""View for the crossdomain.xml file.
Its sole purpose is to serve static/crossdomain.xml as
http://myapp/crossdomain.xml (Flash only looks for cross-domain policies at
the root of the server).
"""
resolver = AssetResolver()
asset = resolver.resolve("<package_name>:static/crossdomain.xml")
response = Response(content_type="text/xml")
response.app_iter = asset.stream()
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment