Skip to content

Instantly share code, notes, and snippets.

@ionelmc
Last active October 1, 2015 19:57
Show Gist options
  • Select an option

  • Save ionelmc/2047741 to your computer and use it in GitHub Desktop.

Select an option

Save ionelmc/2047741 to your computer and use it in GitHub Desktop.
webserver in a line
python -c "import SimpleHTTPServer, SocketServer, BaseHTTPServer; SimpleHTTPServer.test(SimpleHTTPServer.SimpleHTTPRequestHandler, type('Server', (BaseHTTPServer.HTTPServer, SocketServer.ThreadingMixIn, object), {}))" 9090
# short
python -c "from SimpleHTTPServer import test, BaseHTTPServer as b, SimpleHTTPRequestHandler as h; from SocketServer import ThreadingMixIn as t; test(h, type('Server', (b.HTTPServer, t, object), {}))" 9090
# shorter
python -c "import SimpleHTTPServer as h, SocketServer as s, BaseHTTPServer as b; h.test(h.SimpleHTTPRequestHandler, type('S', (b.HTTPServer, s.ThreadingMixIn, object), {}))" 9090
# this variant disables dns reverse lookups
python -c "import SimpleHTTPServer as h, SocketServer as s, BaseHTTPServer as b; h.test(type('H', (h.SimpleHTTPRequestHandler, object), {'address_string': lambda self: str(self.client_address[0])}), type('S', (b.HTTPServer, s.ThreadingMixIn, object), {}))" 9090
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment