1. Using BaseHTTPServer
from BaseHTTPServer import *
def run(server_class=BaseHTTPServer.HTTPServer,
handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
server_address = ("", 8000)
httpd = server_class(server_address, handler_class)
httpd.server_forever()
2. Using SimplerHTTPServer
import SimpleHTTPServer
import SocketServer
PORT = 8001
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SockerServer.TCPServer(("", PORT), Handler)
print "Serving at port: ', PORT
httpd.serve_forever()Or you can invoke it using
python.exe -m SimpleHTTPServer 8000
No comments:
Post a Comment