<commit_before>require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'haml'

set :bind, '0.0.0.0'
set :environment, :production

KNOW_TYPES=%w(png jpg jpeg)
IMGFOLDER=ENV['IMGFOLDER']
unless IMGFOLDER
  raise Exception.new("IMGFOLDER Environment variable is not set")
end
unless File.exist?(IMGFOLDER)
  raise Exception.new("'#{IMGFOLDER}' does not exists.")
end

get '/' do
  @images = KNOW_TYPES.map {|t| Dir.glob("#{IMGFOLDER}/**/*.#{t}") }.flatten.
    map { |i| "img/#{i.gsub(IMGFOLDER+'/', '')}" }
  haml :index, :format => :html5
end

get '/img/*' do
  image = "#{IMGFOLDER}#{params[:splat].join('/')}"
  send_file(image)
end<commit_msg>fix for IMGFOLDER without ending slash<commit_after>require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'haml'

set :bind, '0.0.0.0'
set :environment, :production

KNOW_TYPES=%w(png jpg jpeg)
IMGFOLDER=ENV['IMGFOLDER']
unless IMGFOLDER
  raise Exception.new("IMGFOLDER Environment variable is not set")
end
unless File.exist?(IMGFOLDER)
  raise Exception.new("'#{IMGFOLDER}' does not exists.")
end

get '/' do
  @images = KNOW_TYPES.map {|t| Dir.glob("#{IMGFOLDER}/**/*.#{t}") }.flatten.
    map { |i| "img/#{i.gsub(IMGFOLDER+'/', '')}" }
  haml :index, :format => :html5
end

get '/img/*' do
  image = "#{IMGFOLDER}/#{params[:splat].join('/')}"
  send_file(image)
end
{'fraction_non_alphanumeric': 0.1956845238095238, 'fraction_numerical': 0.00744047619047619, 'mean_word_length': 5.085972850678733, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3451187', 'n_tokens_mistral': 546, 'n_tokens_neox': 552, 'n_words': 120}