A simple Ruby webserver for your testing infrastructure

On occasion, I run into the need to host some files on a web server to perform some testing. Whether it’s testing an embedded solution on smart, multi-function printers, serving files for mobile testing or facilitating some piece of automation, it’s nice to have a throw away web server when you need it.

Several scripting languages can pull this off, but since I’m partial to Ruby, I thought I’d offer up the Ruby flavored one-liner I use on occasion. I find this useful as it’s easy to just whip out on a command line any time I need it or fold it into more complex workflows.

Just type this in at the command line, assuming you have Ruby installed, and you’ll have a simple little file server up and running in seconds:

ruby -run -e httpd . -p 5000

Just a quick breakdown on what we’ve done here:

ruby -run -e
httpd .
-p 5000

To kill it, a simple CTRL + c will end your process.

I have a log hoarder version I’ll share later.

 
1
Kudos
 
1
Kudos

Now read this

New Context, New Beginning

I started this blog with high hopes. However, due to certain constraints, it has made more sense to hold some commentary until a more appropriate context presented itself. That time is quickly approaching. I have roughly a dozen articles... Continue →