add method to add Access-Control-Allow-Origin to HttpFileResponses
This commit is contained in:
parent
34691832eb
commit
1c871f4d31
1 changed files with 7 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue