Skip to content

Instantly share code, notes, and snippets.

@mjc-gh
Created August 11, 2011 18:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjc-gh/1140424 to your computer and use it in GitHub Desktop.
Save mjc-gh/1140424 to your computer and use it in GitHub Desktop.
rserve Utility Script
#!/usr/bin/env ruby
require 'sinatra'
# simple script to serve static files from an arbitrary directory via Sinatra
# usage: rserve [/path/to/dir] [port]
# path will default to '.'
pub = File.expand_path(ARGV.shift || '.')
puts "Setting Public to #{pub}"
set :method_overide, false
set :public_folder, pub
set :port, ARGV.shift || 4567
# redirect '/' to 'index.html'
get '/' do
redirect '/index.html'
end
# redirect POST to GET... hacky, I know ;)
post '*' do
redirect params[:splat].join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment