Skip to content

Instantly share code, notes, and snippets.

@suruseas
Created August 27, 2012 14:57
Show Gist options
  • Save suruseas/3489254 to your computer and use it in GitHub Desktop.
Save suruseas/3489254 to your computer and use it in GitHub Desktop.
デザイン作成時等、静的HTMLサーバをたてるときに。publicフォルダにリソース突っ込んでくれればOK.
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