<commit_before>require 'sinatra/base'
require 'json'
require 'csv'
require 'rack/conneg'
require 'i18n'
require 'i18n/backend/fallbacks'
require 'redis'
require 'tilt/erubis'
require 'connection_pool'
require 'dalli'
require 'kramdown'

require_relative 'blocktrain'
require_relative 'sir_handel/helpers'
require_relative 'sir_handel/racks'
require_relative 'sir_handel/tasks'
require_relative 'sir_handel/trends'
require_relative 'sir_handel/next_trains'

Dotenv.load

class DateTime
  def to_s
    strftime('%Y-%m-%dT%H:%M:%S.%L%:z')
  end
end

module SirHandel
  class App < Sinatra::Base
    helpers do
      include SirHandel::Helpers
    end

    cache = Dalli::Client.new((ENV["MEMCACHIER_SERVERS"] || "").split(","),
                              {:username => ENV["MEMCACHIER_USERNAME"],
                               :password => ENV["<PASSWORD>"],
                               :failover => true,
                               :socket_timeout => 1.5,
                               :socket_failure_delay => 0.2,
                               :pool_size => 5
                              })

    set :cache, cache
    set :public_folder, 'public'
    set :views, 'views'
    set :raise_errors, ['cucumber', 'test'].include?(ENV['RACK_ENV'])

    set :default_interval, '10m'

    get '/' do
      respond_to do |wants|
        @title = 'Train Data Demonstrator'

        wants.html do
          erb :index, layout: :default
        end

        wants.json do
          {
            signals: "#{request.scheme}://#{request.env['HTTP_HOST']}/signals",<commit_msg>disable rack iframe protection<commit_after>require 'sinatra/base'
require 'json'
require 'csv'
require 'rack/conneg'
require 'i18n'
require 'i18n/backend/fallbacks'
require 'redis'
require 'tilt/erubis'
require 'connection_pool'
require 'dalli'
require 'kramdown'

require_relative 'blocktrain'
require_relative 'sir_handel/helpers'
require_relative 'sir_handel/racks'
require_relative 'sir_handel/tasks'
require_relative 'sir_handel/trends'
require_relative 'sir_handel/next_trains'

Dotenv.load

class DateTime
  def to_s
    strftime('%Y-%m-%dT%H:%M:%S.%L%:z')
  end
end

module SirHandel
  class App < Sinatra::Base
    helpers do
      include SirHandel::Helpers
    end

    cache = Dalli::Client.new((ENV["MEMCACHIER_SERVERS"] || "").split(","),
                              {:username => ENV["MEMCACHIER_USERNAME"],
                               :password => ENV["<PASSWORD>"],
                               :failover => true,
                               :socket_timeout => 1.5,
                               :socket_failure_delay => 0.2,
                               :pool_size => 5
                              })

    set :cache, cache
    set :public_folder, 'public'
    set :views, 'views'
    set :raise_errors, ['cucumber', 'test'].include?(ENV['RACK_ENV'])

    set :default_interval, '10m'

    set :protection, :except => :frame_options

    get '/' do
      respond_to do |wants|
        @title = 'Train Data Demonstrator'

        wants.html do
          erb :index, layout: :default
        end

        wants.json do
          {
            signals: "#{request.scheme}://#{request.env['HTTP_HOST']}/signals",
{'fraction_non_alphanumeric': 0.12488350419384903, 'fraction_numerical': 0.006834420627524076, 'mean_word_length': 2.245967741935484, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '1308323', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1023, 'n_words': 212}