Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'sinatra'
- module DataConstellation
- puts "Loading DataConstellation"
- class Application < Sinatra::Base
- # Capture URLs ending with /, and if the directory contains index.shtl, redirect there
- get %r{(.*)/$} do
- puts "checking for server-parser"
- dir = params["captures"][0]
- file = "#{dir}/index.shtml".gsub(%r{///*}, '/')
- # Don't know why this doesn't work instead, but Dreamhost makes debugging too hard:
- #file = request.path.inspect+"index.shtml"
- begin
- File.stat "public"+file # Exception if file doesn't exist
- redirect "#{request.url}index.shtml"
- rescue => e
- #"No such file '#{file}', will pass, #{e.class}: #{e.msg}"
- pass
- end
- end
- # Your Sinatra application goes here
- get '/' do
- puts "got /"
- "got /"
- end
- get '/sinatra' do
- puts "got sinatra"
- "Hello from Sinatra on Dreamhost! loaded from #{__FILE__}"
- end
- end
- end
Add Comment
Please, Sign In to add comment