Welcome, guest | Sign In | My Account | Store | Cart

A Simple python script that acts as a web server, and handles requests

Python, 11 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import SimpleHTTPServer
import SocketServer

PORT = 8000

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

httpd = SocketServer.TCPServer(("", PORT), Handler)

print "serving at port", PORT
httpd.serve_forever()

2 comments

Kent Johnson 11 years, 10 months ago  # | flag

This is straight from the documentation...

Alan Franzoni 11 years, 10 months ago  # | flag

You don't even need to create any code.

python -m SimpleHTTPServer <PORT_NUMBER>