Created
August 27, 2012 14:57
-
-
Save suruseas/3489254 to your computer and use it in GitHub Desktop.
デザイン作成時等、静的HTMLサーバをたてるときに。publicフォルダにリソース突っ込んでくれればOK.
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
require 'sinatra' | |
helpers do | |
def directory_index(path) | |
['index.html', 'index.htm' ].map{|i| "./public/#{path}/#{i}" } | |
end | |
end | |
get '*/' do | |
path = request.path_info | |
p path | |
directory_index(path).each do |index| | |
return File.open(index, File::RDONLY) if File.exists?(index) | |
end | |
raise Sinatra::NotFound.new | |
end | |
run Sinatra::Application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment