Posted over 4 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).

Copy
ruby -run -ehttpd . -p8000

Python 2.x offers a similar way.

Copy
python -m SimpleHTTPServer 8000 .

This is the same way with Python 3.x

Copy
python -m http.server

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

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 config.ru, simply run

Copy
rackup

Or, if you have installed Passenger Standalone:

Copy
passenger start

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
about 1 month ago
by Thomas Eisenbarth
Keywords:
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 cookies to improve usability and analyze traffic.
Accept or learn more