1#!/usr/bin/env python2 2 3import socket 4from BaseHTTPServer import HTTPServer 5from SimpleHTTPServer import SimpleHTTPRequestHandler 6 7PORT = 8000 8 9class HTTPServerV6(HTTPServer): 10 address_family = socket.AF_INET6 11 12class RequestHandler(SimpleHTTPRequestHandler): 13 length = 0 14 15 def _set_headers(self): 16 self.send_response(200) 17 self.send_header('Content-Type', 'text/html') 18 self.send_header('Content-Length', str(self.length)) 19 self.end_headers() 20 21 def do_POST(self): 22 payload = "<html><p>Done</p></html>" 23 self.length = len(payload) 24 self._set_headers() 25 self.wfile.write(payload) 26 27def main(): 28 httpd = HTTPServerV6(("", PORT), RequestHandler) 29 print "Serving at port", PORT 30 httpd.serve_forever() 31 32if __name__ == '__main__': 33 main() 34