import subprocess from http.server import BaseHTTPRequestHandler, HTTPServer serverPort = 8000 config = subprocess.check_output( ['chcp', '65001', '&', 'netsh', 'interface', 'ipv4', 'show', 'config'], shell=True) ipv4_ip = \ config.decode('utf-8').split('Configuration for interface "Ethernet"')[1].split('\n')[2].split(' ')[-1] ipv4_mask = \ config.decode('utf-8').split('Configuration for interface "Ethernet"')[1].split('\n')[3].split(' ')[-1][:-1][:-1] ipv4_gateway = \ config.decode('utf-8').split('Configuration for interface "Ethernet"')[1].split('\n')[4].split(' ')[-1] ipv4_dns_1 = \ config.decode('utf-8').split('Configuration for interface "Ethernet"')[1].split('\n')[7].split(' ')[-1] ipv4_dns_2 = \ config.decode('utf-8').split('Configuration for interface "Ethernet"')[1].split('\n')[8].split(' ')[-1] class HttpGetHandler(BaseHTTPRequestHandler): def do_GET(self): if self.path.endswith("/"): self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() html = f"