Created
November 20, 2008 22:50
-
-
Save bhb/27251 to your computer and use it in GitHub Desktop.
This file contains 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' | |
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