Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
One-line web servers

Instant Webservers! Just add electrons!

All these run on localhost:8000 unless otherwise noted and serve the index.html file in the current directory in an insecure session, i.e, open in any browser. All except Python's SimpleHTTPServer allow multiple simultaneous client connections. The Node http-server module is the most robust although none of these is suitable for production. The true one-liners (all but Node) should all run without any dependencies on a standard OS X or Linux install.

Python 2

    python -m SimpleHTTPServer


    python2 -m SimpleHTTPServer

Perl, pure socket-level implementation (!)

    perl -MIO::All -e 'io(":8000")->fork->accept->(sub { $_[0] < io(-x $1 ? "./$1 |" : $1) if /^GET \/(.*) / })'


    ruby -rwebrick -e' => 8000, :DocumentRoot => Dir.pwd).start'


Not quite a one-liner, and it does put stuff in the local dir (the usual npm baggage), but extremely low overhead and high performance as you would expect with Node.

    npm install http-server

N.B. Node also has the simplest possible REST server for testing in if that's what you're really looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.