python快速搭建WebServer
#!/usr/bin/python import SimpleHTTPServer import SocketServer import os PORT = 7777 WEBDIR = "/www/web/xxx_com/" class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler): def translate_path(self, path): os.chdir(WEBDIR) return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self,path) try: httpd = SocketServer.TCPServer(("", PORT), Handler) print "dir %s serving at port %s"%(repr(WEBDIR), PORT) httpd.serve_forever() except:pass
本文来自博客园,作者:CHN.VMAX,转载请注明原文链接:https://www.cnblogs.com/vmax/p/3955980.html