有了这块知识,应该对各类WEB框架有更好的理解吧。。FLASK,DJANGO,WEBPY。。。。
#!/usr/bin/env python from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class RequestHandler(BaseHTTPRequestHandler): def _writeheaders(self): self.send_response(200) self.send_header(‘Content-type‘, ‘text/html‘) self.end_headers() def do_HEAD(self): self._writeheaders() def do_GET(self): self._writeheaders() self.wfile.write(""" <HTML><HEAD><TITLE>sample python page</TITLE></HEAD> <BODY> THIS IS A SAMPLE PAGE. </BODY></HTML>""") serveraddr = (‘‘,8765) srvr = HTTPServer(serveraddr, RequestHandler) srvr.serve_forever()
时间: 2024-10-14 20:58:49