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
8159e9a4
Commit
8159e9a4
authored
Mar 25, 2020
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simple python backend
parent
55d92252
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
backend.py
backend.py
+55
-0
No files found.
backend.py
0 → 100644
View file @
8159e9a4
import
BaseHTTPServer
import
sys
import
socket
class
HTTP6Server
(
BaseHTTPServer
.
HTTPServer
):
address_family
=
socket
.
AF_INET6
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'
:
self
.
wfile
.
write
(
self
.
response
)
else
:
self
.
wfile
.
write
(
'Hello!'
)
def
show_help
():
print
'Invoke: %s ip port domain host'
%
(
sys
.
argv
[
0
])
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
!=
5
:
show_help
()
sys
.
exit
(
1
)
ip
,
port
,
domain
,
host
=
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
)
server
=
server
(
(
ip
,
int
(
port
)),
BackendHandler
)
server
.
CORS_DOMAIN
=
domain
server
.
CORS_ORIGIN
=
host
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