diff --git a/server.rb b/server.rb index 8c90e19..ea564c1 100644 --- a/server.rb +++ b/server.rb @@ -6,6 +6,18 @@ set :port, '35257' USERS = { 'christoffermadsen' => 'lolol' } FILENAME_GENERATOR = lambda {rand(36**6).to_s(36)} +get '/' do + split_log = Array.new + File.open 'uploads.log', 'r' do |log| + log.each_line { |l| split_log << l } + end + + count = split_log.count + latest = split_log[-1] + + body "#{count} image#{unless count == 1 then "s" end} uploaded
" + + "Latest uploaded: #{latest}" +end post '/upload' do user = params['user'] @@ -31,7 +43,7 @@ post '/upload' do end File.open "uploads.log", 'a+' do |log| - log << filename + log << filename + "\n" end return [200, filename]