<commit_before>require 'sinatra'
require 'digest'
require 'prime'
require 'json'

set :bind, '0.0.0.0'

def decode(params)
  JSON.parse(request.body.read).symbolize_keys
end

get '/' do
  'Welcome to the "Distributed Load Testing Using Kubernetes" sample web app\n'
end

post '/login' do
  "/login - device: #{decode(params)[:device]}"
end

post '/metrics' do
  "/metrics - device: #{decode(params)[:device]}, timestamp: {} \n"
end

# Calculate the Nth prime number to use up CPU and time
post '/nth_prime' do
  Prime.first(decode(params)[:primes].to_i).last
end

post '/post_json' do
  data = params['data']
  Digest::MD5.hexdigest data
end
  <commit_msg>Pass correct param to decode JSON<commit_after>require 'sinatra'
require 'digest'
require 'prime'
require 'json'

set :bind, '0.0.0.0'

def decode(request)
  JSON.parse(request.body.read).symbolize_keys
end

get '/' do
  'Welcome to the "Distributed Load Testing Using Kubernetes" sample web app\n'
end

post '/login' do
  "/login - device: #{decode(request)[:device]}"
end

post '/metrics' do
  "/metrics - device: #{decode(request)[:device]}, timestamp: {} \n"
end

# Calculate the Nth prime number to use up CPU and time
post '/nth_prime' do
  Prime.first(decode(request)[:primes].to_i).last
end

post '/post_json' do
  data = params['data']
  Digest::MD5.hexdigest data
end
  
{'fraction_non_alphanumeric': 0.1437125748502994, 'fraction_numerical': 0.0074850299401197605, 'mean_word_length': 4.434959349593496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4801151', 'n_tokens_mistral': 476, 'n_tokens_neox': 463, 'n_words': 143}