Skip to content

Instantly share code, notes, and snippets.

@rye
Last active January 30, 2017 11:38
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rye/11274217 to your computer and use it in GitHub Desktop.
A Ruby web server to act like Python's SimpleHTTPServer module.
#!/usr/bin/env rackup
#\ -E deployment
use Rack::ContentLength
app = Rack::Directory.new Dir.pwd
run app

Background

Often times, when I am editing files on a server, I just want to serve up static HTML, JavaScript, and CSS. In the past, I've just typed python -m SimpleHTTPServer into my terminal and started a web server. That suffices for most things, but I much prefer Ruby over Python. Therefore, I decided to try out using Rackup to build a web server of sorts.

This is the product of that (~10 minutes of hacking).

Setup

Depending on how lazy you are, you could just copy or symlink this into /usr/local/bin and rename to whatever you want to punch into your command-line. I'd be glad to offer help with getting it set up, but I will leave it to you to be creative. On Unix systems, you can just execute the vomit.ru file in this project and it should automatically do what it needs to. If Rack or Ruby is not installed, it won't work, so you should install those before complaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment