Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
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
Thomas Gambier
slapos.package
Commits
b2722b90
Commit
b2722b90
authored
Jun 29, 2015
by
Kristopher Ruzic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds serverside program
just so it doesn't get lost
parent
6c8d5c52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
playbook/roles/test-suite/files/log-server
playbook/roles/test-suite/files/log-server
+58
-0
No files found.
playbook/roles/test-suite/files/log-server
0 → 100644
View file @
b2722b90
#!/usr/bin/python2.7
import
socket
import
errno
import
cgi
import
os
from
BaseHTTPServer
import
BaseHTTPRequestHandler
from
BaseHTTPServer
import
HTTPServer
from
SimpleHTTPServer
import
SimpleHTTPRequestHandler
class
MyHandler
(
BaseHTTPRequestHandler
):
def
do_GET
(
self
):
if
self
.
path
==
'/ip'
:
self
.
send_response
(
200
)
self
.
send_header
(
'Content-type'
,
'text/html'
)
self
.
end_headers
()
self
.
wfile
.
write
(
'Your IP address is %s'
%
self
.
client_address
[
0
])
return
else
:
return
SimpleHTTPRequestHandler
.
do_GET
(
self
)
def
do_POST
(
self
):
form
=
cgi
.
FieldStorage
(
fp
=
self
.
rfile
,
headers
=
self
.
headers
,
environ
=
{
"REQUEST_METHOD"
:
"POST"
}
)
lw
.
write_log
(
form
.
list
[
0
].
value
,
form
.
list
[
1
:])
self
.
send_response
(
200
)
class
HTTPServerV6
(
HTTPServer
):
address_family
=
socket
.
AF_INET6
class
logWriter
():
def
write_log
(
self
,
fp
,
contents
):
print
os
.
path
.
dirname
(
fp
)
try
:
os
.
makedirs
(
os
.
path
.
dirname
(
fp
))
except
OSError
as
exception
:
if
exception
.
errno
!=
errno
.
EEXIST
:
raise
try
:
with
open
(
fp
,
'a'
)
as
myfile
:
for
l
in
contents
:
myfile
.
write
(
l
.
value
)
except
IOError
as
e
:
print
"Unable to open file"
#Does not exist OR no read permissions
with
open
(
fp
,
'w'
)
as
myfile
:
for
l
in
contents
:
myfile
.
write
(
l
.
value
)
print
"Finished writing"
if
__name__
==
'__main__'
:
lw
=
logWriter
()
server
=
HTTPServerV6
((
'::'
,
9000
),
MyHandler
)
print
'Starting server, use <Ctrl-C> to stop'
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