Sha256: 0b2b18fdbbb8ad785ee8e83053eb91976b9469e08afe0e6ba059d210713a65c8
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require 'rubygems' require 'sinatra' class Yankee < Sinatra::Base set :env, :production set :port, 8888 set :static, true # set up static file routing #set :public, File.expand_path('..', __FILE__) # set up the static dir (with images/js/css inside) #set :views, File.expand_path('../views', __FILE__) # set up the views dir #set :haml, { :format => :html5 } # if you use haml before do #raise "XXX - SECURITY - You should set an API key!" #error 401 unless params[:key] =~ /^WHATEVER/ end get '/' do sort = params["sort"] if sort == "Modified" entries = Dir.entries('.').sort_by { |x| File.mtime(x) } else entries = Dir.entries('.').sort_by { |x| File.size(x) } end out = [] out << "<table>" out << "<tr><td>Filename</td><td><a href=/?sort=>Size</a><td><td><a href=/?sort=Modified>Modified</a><td></tr><br/>" entries.map do |e| out << "<tr><td>#{e}</td><td>#{File.size(e)}<td><td>#{File.mtime(e)}<td></tr><br/>" end out << "</table>" out.join("\n") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yankee-0.0.5 | api.rb |