Created
August 11, 2011 18:50
-
-
Save mjc-gh/1140424 to your computer and use it in GitHub Desktop.
rserve Utility Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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