|
|
@@ -0,0 +1,67 @@ |
|
|
|
import http.server |
|
|
|
import urllib.parse |
|
|
|
|
|
|
|
|
|
|
|
class EingenerHandler(http.server.BaseHTTPRequestHandler): |
|
|
|
|
|
|
|
def do_GET(self): |
|
|
|
self.send_response(200) |
|
|
|
self.end_headers() |
|
|
|
|
|
|
|
parsed = urllib.parse.urlparse(self.path) |
|
|
|
query = parsed.query |
|
|
|
query_components = urllib.parse.parse_qsl(query) |
|
|
|
|
|
|
|
query_params = list(query_components) |
|
|
|
|
|
|
|
param1, param2 = None, None |
|
|
|
response = "" |
|
|
|
|
|
|
|
if len(query_params) > 0: |
|
|
|
param1 = int(query_params[0][1]) |
|
|
|
param2 = int(query_params[1][1]) |
|
|
|
|
|
|
|
for i in range(param1, param2 + 1): |
|
|
|
response += "<tr><td>{}</td>\n<td>{}</td></tr>\n".format(i, i * i) |
|
|
|
|
|
|
|
message = """ |
|
|
|
<html> |
|
|
|
<head> |
|
|
|
<title>Meine Aufgabe</title> |
|
|
|
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon"> |
|
|
|
|
|
|
|
<style> |
|
|
|
|
|
|
|
h1 { |
|
|
|
color: white; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
p { |
|
|
|
font-family: verdana; |
|
|
|
font-size: 20px; |
|
|
|
} |
|
|
|
|
|
|
|
table, td, tr { |
|
|
|
border: 1px solid black; |
|
|
|
} |
|
|
|
</style> |
|
|
|
</head> |
|
|
|
|
|
|
|
<body> |
|
|
|
<h1>Aufgabe : Quadratzahlen</h1> |
|
|
|
<table>""" + response + """ |
|
|
|
</table> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
self.wfile.write(message.encode('utf-8')) |
|
|
|
|
|
|
|
|
|
|
|
Port = 2323 |
|
|
|
Handler = EingenerHandler |
|
|
|
address = ('', Port) |
|
|
|
server = http.server.HTTPServer(address, Handler) |
|
|
|
server.serve_forever() |