import os, socket, http.server, socketserver, sys

PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 5230
os.chdir(os.path.join(os.path.dirname(__file__), '..'))

class S(socketserver.ThreadingTCPServer):
    address_family = socket.AF_INET6
    allow_reuse_address = True
    def server_bind(self):
        self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
        super().server_bind()

S(('::', PORT), http.server.SimpleHTTPRequestHandler).serve_forever()
