Browse Source

aufgabe2 (quadratZahlen)

master
Nadege 5 years ago
parent
commit
c408cfb464
1 changed files with 67 additions and 0 deletions
  1. 67
    0
      Aufgabe2/quadrat.py

+ 67
- 0
Aufgabe2/quadrat.py View File

@@ -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()

Loading…
Cancel
Save