praktikum
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.

Quadratzahlen.py 829B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334
  1. import http.server
  2. import urllib.parse
  3. class newHandler(http.server.BaseHTTPRequestHandler):
  4. def do_GET(self):
  5. self.send_response(200)
  6. self.end_headers()
  7. parseUrl = urllib.parse.urlparse(self.path)
  8. path = parseUrl.path
  9. query = parseUrl.query
  10. query_components = urllib.parse.parse_qsl(query)
  11. ende = int(query_components[1][1])
  12. start = int(query_components[0][1])
  13. msg = "<table border='1'>"
  14. while(start <= ende):
  15. msg += "<tr><td>" + str(start) + "</td>" + "<td>" + str(start*start) + "</td>" + "</tr>"
  16. start += 1
  17. msg += "</table>"
  18. self.wfile.write(msg.encode('utf-8'))
  19. PORT = 4096
  20. HANDLER = newHandler
  21. ADDRESS = ('', PORT)
  22. SERVER = http.server.HTTPServer(ADDRESS, HANDLER)
  23. SERVER.serve_forever()