Skip to content

Instantly share code, notes, and snippets.

@joecorcoran
Forked from bhb/butler.rb
Created July 10, 2009 11:16
Show Gist options
  • Save joecorcoran/144407 to your computer and use it in GitHub Desktop.
Save joecorcoran/144407 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'pathname'
get "/" do
html = "<h1>Your files, sir.</h1>"
dir = "./files/"
Dir[dir+"*"].each do |file|
html+=file_link(file)
end
html
end
helpers do
def file_link(file)
filename = Pathname.new(file).basename
"<a href='#{file}'>#{filename}</a><br/>"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment