这是我的代码:
from http.server import HTTPServer, BaseHTTPRequestHandler
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(b'some text')
def redirect(location):
# redirect
server = HTTPServer(('localhost', 1111), Handler)
server.serve_forever()
如何编写函数以从路径重定向到另一个路径?