Tomasz Pewinski

Instant http server with python

Here’s an extremely useful one-liner that I’ve been using for ages. It starts a http server with the root in current directory, using python which is most likely already installed on your machine if you’re using Linux or OSX.

python -m SimpleHTTPServer

If you go to http://localhost:8000 you’ll see index.html if it’s present in current directory.

You can also boot up the server on any other port like this:

python -m SimpleHTTPServer 8888

It’s useful for development, for example of Single Page Applications. Enjoy :)

EDIT:

There’s how to do it in ruby:

ruby -run -e httpd -- -p 8000 .

Ironically I always used python one even though I use ruby far more often :)

comments powered by Disqus