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

 

上一篇:《Web前端工程师修炼之道(原书第4版)》——自适应Web设计


下一篇:QT中的OpcDa 客户端 实现