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.

YingYang.py 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import http.server
  2. def page(path):
  3. print(path)
  4. match path:
  5. case "/ying.html":
  6. return """
  7. <html>
  8. <head>
  9. <title> YingYang </title>
  10. </head>
  11. <body>
  12. <div> <b>Ying</b> </div>
  13. <div> <a href="yang.html">The second word of power...</a> </div>
  14. </body>
  15. </html>
  16. """
  17. case "/yang.html":
  18. return """
  19. <html>
  20. <head>
  21. <title> YingYang </title>
  22. </head>
  23. <body>
  24. <div> <b>Yang</b> </div>
  25. <div> <a href="ying.html">The first word of power...</a> </div>
  26. </body>
  27. </html>
  28. """
  29. class EigenerHandler(http.server.BaseHTTPRequestHandler):
  30. def do_GET(self):
  31. self.send_response(200)
  32. self.send_header('Content-type', 'text-html')
  33. self.end_headers()
  34. msg = page(self.path)
  35. self.wfile.write(msg.encode('utf-8'))
  36. port = 12345
  37. handler = EigenerHandler
  38. address = ('', port)
  39. server = http.server.HTTPServer(address, handler)
  40. server.serve_forever()