Mercurial > hg > RequestDumpster
comparison requestdumpster/dumpster.py @ 16:9ef205ebb047 default tip
CORS
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 12 Dec 2016 15:26:40 -0800 |
parents | d2585c78e70f |
children |
comparison
equal
deleted
inserted
replaced
15:d2585c78e70f | 16:9ef205ebb047 |
---|---|
39 if self.directory: | 39 if self.directory: |
40 filename = '{0}'.format(time.time()) | 40 filename = '{0}'.format(time.time()) |
41 with open(os.path.join(self.directory, filename), 'w') as f: | 41 with open(os.path.join(self.directory, filename), 'w') as f: |
42 f.write(body) | 42 f.write(body) |
43 | 43 |
44 # CORS | |
45 headers = [('Access-Control-Allow-Origin', '*')] | |
46 headers.append(('Access-Control-Allow-Headers', | |
47 ', '.join(request.headers.keys()))) | |
48 headers.append(('Access-Control-Allow-Methods', | |
49 'GET, POST, DELETE, PUT, PATCH, OPTIONS')) | |
50 | |
44 response = Response(content_type='text/plain', | 51 response = Response(content_type='text/plain', |
45 body=body) | 52 body=body) |
53 for key, value in headers: | |
54 response.headers.add(key, value) | |
46 return response(environ, start_response) | 55 return response(environ, start_response) |
47 | 56 |
48 def main(args=sys.argv[1:]): | 57 def main(args=sys.argv[1:]): |
49 """CLI""" | 58 """CLI""" |
50 | 59 |