Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env ruby
  2. require 'sinatra'
  3.  
  4. # simple script to serve static files from an arbitrary directory via Sinatra
  5. # usage: rserve /path/to/dir (defaults to the current directory)
  6.  
  7. pub = File.expand_path( File.dirname(ARGV.first || '.') )
  8. puts "Setting Public to #{pub}"
  9.  
  10. set :method_overide, false
  11. set :public, pub
  12.  
  13. # redirect '/' to 'index.html'
  14. get '/' do
  15.   redirect '/index.html'
  16. end
  17.  
  18. # redirect POST to GET... hacky, I know ;)
  19. post '*' do
  20.   redirect params[:splat].join
  21. end