import functools def allow_cross_site_request(f): """Allow other sites to access this resource, see https://developer.mozilla.org/en/HTTP_access_control.""" @functools.wraps(f) def wrapper(request, *args, **kw): response = f(request, *args, **kw) """If Access-Control-Allow-Credentials isn't set, the browser won't return data required cookies to see. This is a good thing, let's keep it that way.""" response['Access-Control-Allow-Origin'] = '*' response['Access-Control-Allow-Methods'] = 'GET' return response return wrapper