<commit_before># SpaceX API for searching company info,
# vehicle info, launch sites, and
# launch data.


require 'sinatra'
require 'sinatra/subdomain'
require 'json'
require 'date'
require 'mysql2'
require './data/company_info.rb'
require './data/falcon9.rb'
require './data/home_info.rb'
require './data/falcon_heavy.rb'
require './data/launchpads.rb'
require './data/dragon.rb'


# DB connection to MariaDB
DB = Mysql2::Client.new(:host => ENV["MARIA_HOST"], :username => ENV["MARIA_USER"], :password => ENV["<PASSWORD>"], :database => ENV["MARIA_DB"], :reconnect => true)


# Disables rack protection because of false positives
# that were blocking connections to home page
disable :protection


# No longer necessary
# Forces the use of HTTPS for the API
#before do
#  redirect request.url.sub('http', 'https') unless request.secure?
#end

# Method for merging hashes of static data
def hash_merge *hashes
  hashes.inject :merge
end

# Uses subdomain api.example.com to route traffic
subdomain :api do

get '/' do
  content_type :json
  JSON.pretty_generate($home_info)
end

get '/info' do
  content_type :json
  JSON.pretty_generate($company_info)<commit_msg>added 404 error handler for bad api requests<commit_after># SpaceX API for searching company info,
# vehicle info, launch sites, and
# launch data.


require 'sinatra'
require 'sinatra/subdomain'
require 'json'
require 'date'
require 'mysql2'
require './data/company_info.rb'
require './data/falcon9.rb'
require './data/home_info.rb'
require './data/falcon_heavy.rb'
require './data/launchpads.rb'
require './data/dragon.rb'


# DB connection to MariaDB
DB = Mysql2::Client.new(:host => ENV["MARIA_HOST"], :username => ENV["MARIA_USER"], :password => ENV["<PASSWORD>"], :database => ENV["MARIA_DB"], :reconnect => true)


# Disables rack protection because of false positives
# that were blocking connections to home page
disable :protection


# No longer necessary
# Forces the use of HTTPS for the API
#before do
#  redirect request.url.sub('http', 'https') unless request.secure?
#end

# Method for merging hashes of static data
def hash_merge *hashes
  hashes.inject :merge
end

# Uses subdomain api.example.com to route traffic
subdomain :api do

# 404 Error!
not_found do
  status 404
  erb :oops
end

get '/' do
  content_type :json
  JSON.pretty_generate($home_info)
end

get '/info' do
  content_type :json
  JSON.pretty_generate($company_info)
{'fraction_non_alphanumeric': 0.12029764365440264, 'fraction_numerical': 0.0062009094667217855, 'mean_word_length': 4.831325301204819, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '3530270', 'n_tokens_mistral': 811, 'n_tokens_neox': 766, 'n_words': 255}