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 http://127.0.0.1:8000 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 -m SimpleHTTPServer
or
python2 -m SimpleHTTPServer
perl -MIO::All -e 'io(":8000")->fork->accept->(sub { $_[0] < io(-x $1 ? "./$1 |" : $1) if /^GET \/(.*) / })'
ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 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
http-server
N.B. Node also has the simplest possible REST server for testing in http://stub.by/ if that's what you're really looking for.