From 611321aefb9ba0786e4a9702fac5d89fa5407192 Mon Sep 17 00:00:00 2001 From: Generic Username Date: Fri, 4 Apr 2014 17:16:49 +0200 Subject: [PATCH] server for clientside and serving to other nodes --- serve.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 serve.py diff --git a/serve.py b/serve.py new file mode 100644 index 0000000..d538c59 --- /dev/null +++ b/serve.py @@ -0,0 +1,24 @@ +import socket +from BaseHTTPServer import HTTPServer +from SimpleHTTPServer import SimpleHTTPRequestHandler + +class MyHandler(SimpleHTTPRequestHandler): + 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) + +class HTTPServerV6(HTTPServer): + address_family = socket.AF_INET6 + +def main(): + server = HTTPServerV6(('::', 13338), MyHandler) + server.serve_forever() + +if __name__ == '__main__': + main()