Prak1 Nachbearbeitung

This commit is contained in:
Tobias Hohwieler 2021-10-22 12:20:43 +02:00
parent 0f9a07e04a
commit f779e96df6
2 changed files with 32 additions and 13 deletions

View File

@ -1,23 +1,43 @@
import http.server import http.server
def page(path):
print(path)
match path:
case "/ying.html":
return """
<html>
<head>
<title> YingYang </title>
</head>
<body>
<div> <b>Ying</b> </div>
<div> <a href="yang.html">The second word of power...</a> </div>
</body>
</html>
"""
case "/yang.html":
return """
<html>
<head>
<title> YingYang </title>
</head>
<body>
<div> <b>Yang</b> </div>
<div> <a href="ying.html">The first word of power...</a> </div>
</body>
</html>
"""
class EigenerHandler(http.server.BaseHTTPRequestHandler): class EigenerHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self): def do_GET(self):
self.send_response(200) self.send_response(200)
self.send_header('Content-tyoe', 'text-html') self.send_header('Content-type', 'text-html')
self.end_headers() self.end_headers()
msg = page(self.path)
msg = """
<html>
<head>
<title> YingYang </title>
</head>
<body>
<b>Ying</b>
</body>
</html>
"""
self.wfile.write(msg.encode('utf-8')) self.wfile.write(msg.encode('utf-8'))

View File

@ -12,7 +12,6 @@ port = 12345
s.connect((host, port)) s.connect((host, port))
while True: while True:
msg = input('Wort eingeben: ') msg = input('Wort eingeben: ')
if msg != 'STOP': if msg != 'STOP':
s.send(msg.encode('utf-8')) s.send(msg.encode('utf-8'))