import http.server | |||||
class EingenerHandler(http.server.BaseHTTPRequestHandler): | |||||
def do_GET(self): | |||||
self.send_response(200) | |||||
self.end_headers() | |||||
if self.path == '/': | |||||
self.path = '/ying.html' | |||||
msg = open(self.path[1:]).read() | |||||
self.wfile.write(bytes(msg, 'utf-8')) | |||||
Port = 2020 | |||||
Handler = EingenerHandler | |||||
address = ('', Port) | |||||
server = http.server.HTTPServer(address, Handler) | |||||
server.serve_forever() |
<!DOCTYPE html> | |||||
<html lang="en"> | |||||
<head> | |||||
<meta charset="UTF-8"> | |||||
<title>Python is awesome!</title> | |||||
</head> | |||||
<body> | |||||
<h1>Yang</h1> | |||||
<a href="ying.html" style="font-size: 25px">Ying</a> | |||||
</body> | |||||
</html> |
<!DOCTYPE html> | |||||
<html lang="en"> | |||||
<head> | |||||
<meta charset="UTF-8"> | |||||
<title>Python is awesome!</title> | |||||
</head> | |||||
<body> | |||||
<h1>Ying</h1> | |||||
<a href="yang.html" style="font-size: 25px">Yang</a> | |||||
</body> | |||||
</html> |