Posted about 5 years ago. Visible to the public.

How to run a small web server (one-liner)

Sometimes you just want to have a small web server that serves files to test something.

Serve the current directory

On Ruby 1.9.2+ you can do the following ("." for current directory).

ruby -run -ehttpd . -p8000

Python 2.x offers a similar way.

python -m SimpleHTTPServer 8000 .

This is the same way with Python 3.x

python -m http.server

In both cases your web server is single-threaded and will block when large files are being downloaded from you.

WEBrick also offers a simple way to serve your files via HTTPS:

ruby -r webrick/https -e ' Port: 8000, DocumentRoot: ".", SSLEnable: true, SSLCertName: [%w[CN localhost]] ).start'

For solutions in many other languages, see the big list of http static server one-liners.

Running a Rack application

To boot an application that comes with a, simply run


Or, if you have installed Passenger Standalone:

passenger start

For HTTPS, use this snippet:

puma -b ssl://localhost:8000

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Arne Hartherz
Last edit:
10 months ago
by Michael Leimstädtner
webserver, local, oneliner
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more