Skip to content

Instantly share code, notes, and snippets.

@bhb
Created November 20, 2008 22:52
Show Gist options
  • Save bhb/27253 to your computer and use it in GitHub Desktop.
Save bhb/27253 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'pathname'
get "/" do
dir = "./files/"
@links = Dir[dir+"*"].map { |file|
file_link(file)
}.join
erb :index
end
helpers do
def file_link(file)
filename = Pathname.new(file).basename
"<a href='#{file}'>#{filename}</a><br/>"
end
end
use_in_file_templates!
__END__
@@ index
<html>
<head>
</head>
<body>
<h1>Your files, sir.</h1>
<%= @links %>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment