Last active
October 1, 2015 19:57
-
-
Save ionelmc/2047741 to your computer and use it in GitHub Desktop.
webserver in a line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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