Guest User

Untitled

a guest
Jun 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. require 'rubygems'
  2. require 'sinatra'
  3.  
  4. module DataConstellation
  5. puts "Loading DataConstellation"
  6. class Application < Sinatra::Base
  7. # Capture URLs ending with /, and if the directory contains index.shtl, redirect there
  8. get %r{(.*)/$} do
  9. puts "checking for server-parser"
  10. dir = params["captures"][0]
  11. file = "#{dir}/index.shtml".gsub(%r{///*}, '/')
  12. # Don't know why this doesn't work instead, but Dreamhost makes debugging too hard:
  13. #file = request.path.inspect+"index.shtml"
  14. begin
  15. File.stat "public"+file # Exception if file doesn't exist
  16. redirect "#{request.url}index.shtml"
  17. rescue => e
  18. #"No such file '#{file}', will pass, #{e.class}: #{e.msg}"
  19. pass
  20. end
  21. end
  22.  
  23. # Your Sinatra application goes here
  24.  
  25. get '/' do
  26. puts "got /"
  27. "got /"
  28. end
  29.  
  30. get '/sinatra' do
  31. puts "got sinatra"
  32. "Hello from Sinatra on Dreamhost! loaded from #{__FILE__}"
  33. end
  34. end
  35. end
Add Comment
Please, Sign In to add comment