Simple webserver

The SimpleHTTPServer module can be used in the following manner in order to set up a very basic web server serving files relative to the current directory.

import SimpleHTTPServer
import SocketServer

PORT = 8000

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

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

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

The SimpleHTTPServer module can also be invoked directly using the -m switch of the interpreter with a port number argument. Similar to the previous example, this serves the files relative to the current directory.

python -m SimpleHTTPServer 8000

Now can be started via

python3 -m http.server 8000