本代码运行后会减轻8088端口,用户访问:http://127.0.0.1:8088 或输出html代码:Hello World!
#!/usr/bin/python import BaseHTTPServer class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header('Content-type','text/html') self.end_headers() self.wfile.write('<html><body>Hello, world !</body></html>') return print "Listening on port 8088..." server = BaseHTTPServer.HTTPServer(('', 8088), MyHandler) server.serve_forever()
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8055.html