Commit 5a0e6894 authored by Łukasz Nowak's avatar Łukasz Nowak

Drop not needed header

parent 8159e9a4
......@@ -9,19 +9,11 @@ class HTTP6Server(BaseHTTPServer.HTTPServer):
class BackendHandler(BaseHTTPServer.BaseHTTPRequestHandler):
response = 'ThisIsResponse' * 10
content_security_policy = """"default-src 'none'; img-src 'self' data:; """ \
"""media-src 'self'; connect-src 'self' %s; script-src 'self' """ \
"""'unsafe-eval'; font-src netdna.bootstrapcdn.com; style-src """ \
"""'self' netdna.bootstrapcdn.com 'unsafe-inline' data:; frame-src """ \
"""'self' data:"""
def do_GET(self):
self.send_response(200)
self.send_header('X-Frame-Options', 'SAMEORIGIN')
self.send_header('X-Content-Type-Options', 'nosniff')
self.send_header(
'Content-Security-Policy',
self.content_security_policy % (self.server.CORS_DOMAIN,))
self.send_header('Access-Control-Allow-Origin', self.server.CORS_ORIGIN)
self.end_headers()
if self.path == '/test':
......@@ -31,25 +23,24 @@ class BackendHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def show_help():
print 'Invoke: %s ip port domain host' % (sys.argv[0])
print 'Invoke: %s ip port cors' % (sys.argv[0])
if __name__ == '__main__':
if len(sys.argv) != 5:
if len(sys.argv) != 4:
show_help()
sys.exit(1)
ip, port, domain, host = sys.argv[1:]
ip, port, cors = sys.argv[1:]
if ':' in ip:
ip_ = '[%s]' % (ip,)
server = HTTP6Server
else:
ip_ = ip
server = BaseHTTPServer.HTTPServer
print 'Serving on http://%s:%s/ with allowed domain %s on host %s' % (
ip_, port, domain, host)
print 'Serving on http://%s:%s/ with CORS set to %s' % (
ip_, port, cors)
server = server(
(ip, int(port)),
BackendHandler)
server.CORS_DOMAIN = domain
server.CORS_ORIGIN = host
server.CORS_ORIGIN = cors
server.serve_forever()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment