Friday, February 23, 2007

Standard Gems: SimpleHTTPServer.test()

Have you ever needed to share some files real quick with real low setup? You can start up a web server from the current directory on port 8000 with a single line of python.

python -c "from SimpleHTTPServer import test; test()"

5 comments:

Tim Golden said...

Even simpler (in recent versions):

python -m SimpleHTTPServer

Colin said...

Nice! I used to keep a copy of 'a-ftp.exe' around for simple file sharing, but it seems MSFT has tagged it as spyware and started deleting it :(

Very handy, thanks.

Roger Erens said...

With Billy Joex' new pyftpdlib something alike is possible for an FTP-server:
python -m pyftpdlib.FTPServer

see
http://billiejoex.altervista.org/pyftpdlib.html

Bill Mill said...

Here's a quick hack to serve a non-8000 port, 19028 in this case:

python -c "from SimpleHTTPServer import test; import sys; sys.argv = [None, 19028]; test()"

Anonymous said...

Hey Bill, more concise:
python -c "from SimpleHTTPServer import t; t()" 19028

I write here about programming, how to program better, things I think are neat and are related to programming. I might write other things at my personal website.

I am happily employed by the excellent Caktus Group, located in beautiful and friendly Carrboro, NC, where I work with Python, Django, and Javascript.

Blog Archive