<commit_before>require 'bundler'
require 'json'
require 'securerandom'
require 'time'
Bundler.require :default
require 'sinatra/reloader' if development?

configure do
  DB = begin
    Sequel.connect('')
  rescue
    Sequel.connect('sqlite://test.db')
  end
  
  require './models'
end

helpers do
  def a(href, text, o = {})
    o[:rel] = o[:rel] ? "rel=\"#{[o[:rel]].join(' ')}\" " : ""
    o[:title] = o[:title] ? "title=\"#{[o[:title]].join(' ')}\" " : ""
    "<a #{o[:rel]}#{o[:title]}href=\"#{href}\">#{text}</a>"
  end
end

before '/api/*' do
  content_type 'application/json'
end

helpers do
  def read_json_params(parms)
    begin
      request.body.rewind
      j = JSON.parse request.body.read
      parms[:json] = true
      j.each { |k,i|
        parms["_#{k}"] = parms[k] if parms[k]
        parms[k] = i<commit_msg>Explicit production db from ENV<commit_after>require 'bundler'
require 'json'
require 'securerandom'
require 'time'
Bundler.require :default
require 'sinatra/reloader' if development?

configure do
  DB = begin
    Sequel.connect(ENV['DATABASE_URL'])
  rescue
    Sequel.connect('sqlite://test.db')
  end
  
  require './models'
end

helpers do
  def a(href, text, o = {})
    o[:rel] = o[:rel] ? "rel=\"#{[o[:rel]].join(' ')}\" " : ""
    o[:title] = o[:title] ? "title=\"#{[o[:title]].join(' ')}\" " : ""
    "<a #{o[:rel]}#{o[:title]}href=\"#{href}\">#{text}</a>"
  end
end

before '/api/*' do
  content_type 'application/json'
end

helpers do
  def read_json_params(parms)
    begin
      request.body.rewind
      j = JSON.parse request.body.read
      parms[:json] = true
      j.each { |k,i|
        parms["_#{k}"] = parms[k] if parms[k]
        parms[k] = i
{'fraction_non_alphanumeric': 0.20766961651917404, 'fraction_numerical': 0.0, 'mean_word_length': 3.208436724565757, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4830617', 'n_tokens_mistral': 642, 'n_tokens_neox': 657, 'n_words': 135}