Web server on demmand

import sys, BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
 
HandlerClass=SimpleHTTPRequestHandler
ServerClass=BaseHTTPServer.HTTPServer
 
protocol = "HTTP/1.0"
host = "192.168.0.185"
port = 8888
server_address = (host, port)
HandlerClass.protocol_version = protocol
httpd = ServerClass(server_address, HandlerClass)
 
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()

The above example serves all pages/files in the current directory, as long as the host:port combination is accessible.

Great if you want to quickly test javascript or send a document to your iphone!