add method to add Access-Control-Allow-Origin to HttpFileResponses

This commit is contained in:
j 2014-02-05 06:37:37 +00:00
parent 34691832eb
commit 1c871f4d31

View file

@ -47,5 +47,12 @@ def HttpFileResponse(path, content_type=None, filename=None):
response['Content-Disposition'] = 'attachment; filename*=UTF=8''%s' % quote(filename)
response['Expires'] = datetime.strftime(datetime.utcnow() + timedelta(days=1), "%a, %d-%b-%Y %H:%M:%S GMT")
def allow_access():
for key in ('X-Accel-Redirect', 'X-Sendfile'):
if key in response:
del response[key]
response['Access-Control-Allow-Origin'] = '*'
response.allow_access = allow_access
return response