|
123456789101112131415161718192021222324252627 |
- import http.server
- import urllib.parse
-
- class newHandler(http.server.BaseHTTPRequestHandler):
-
- def do_GET(self):
- self.send_response(200)
- self.end_headers()
-
- parseUrl = urllib.parse.urlparse(self.path)
- path = parseUrl.path
-
- if path == "/Yang":
- msg1 = "<a href='/Ying'>" + path + "</a>"
- elif path == "/Ying":
- msg1 = "<a href='/Yang'>" + path + "</a>"
-
- self.wfile.write(msg1.encode('utf-8'))
-
-
-
- PORT = 4096
- HANDLER = newHandler
- ADDRESS = ('', PORT)
-
- SERVER = http.server.HTTPServer(ADDRESS, HANDLER)
- SERVER.serve_forever()
|