Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
frontend-selector
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
frontend-selector
Commits
5a0e6894
Commit
5a0e6894
authored
Mar 25, 2020
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop not needed header
parent
8159e9a4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
15 deletions
+6
-15
backend.py
backend.py
+6
-15
No files found.
backend.py
View file @
5a0e6894
...
...
@@ -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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment