You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

quadratzahlenServ.py 876B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import http.server
  2. import urllib.parse
  3. class MyHandler(http.server.BaseHTTPRequestHandler):
  4. def do_GET(self):
  5. self.send_response(200)
  6. self.end_headers()
  7. parsed = urllib.parse.urlparse(self.path)
  8. path = parsed.path
  9. query = parsed.query
  10. query_components = urllib.parse.parse_qsl(query)
  11. start = query_components["von="]
  12. end = query_components["bis="]
  13. msg = """
  14. <html>
  15. <head>
  16. <title>Quadratzahlen</title>
  17. </head>
  18. <body>
  19. {}
  20. {}
  21. </body>
  22. </html>
  23. """.format(start, end)
  24. self.wfile.write(msg.encode('utf-8'))
  25. port = 12345
  26. handler = MyHandler
  27. address = ('', port)
  28. server = http.server.HTTPServer(address, handler)
  29. server.serve_forever()