<commit_before>open Core_kernel.Std
open Opium.Std
open Db

let print_hello s req =
  App.respond' (`String ("hello" ^ s))
       
let print_json req =
  try
    App.json_of_body_exn req >>| fun json ->
    respond (`String ("Received response\n" ^ Ezjsonm.to_string json ^ "\n"))
  with
  | _ -> let json = Ezjsonm.from_string "{\"message\": \"Ill-formed json\"}" in
	   respond' (`Json json)
	    
(*let string_of_scores scores =
  scores.(0).(0)
  
let print_scores req =
  let scores = scores 0 in
  App.respond' (`String (string_of_scores scores))*)
  
let _ =
  try
    let c = connect () in
    let req = "CREATE TABLE IF NOT EXISTS table (
	       user varchar NOT NULL,
	       password varchar NOT NULL,
	       problem integer NOT NULL,
	       score integer NOT NULL
	     )" in
    let res = c#exec req in
    App.empty
      |> post "/" print_json
      |> get "/" (print_hello res#error)
      |> App.run_command
  with
  | _ -> App.empty
	 |> post "/" print_json
	 |> get "/" (print_hello " people")
	 |> App.run_command<commit_msg>my_table<commit_after>open Core_kernel.Std
open Opium.Std
open Db

let print_hello s req =
  App.respond' (`String ("hello" ^ s))
       
let print_json req =
  try
    App.json_of_body_exn req >>| fun json ->
    respond (`String ("Received response\n" ^ Ezjsonm.to_string json ^ "\n"))
  with
  | _ -> let json = Ezjsonm.from_string "{\"message\": \"Ill-formed json\"}" in
	   respond' (`Json json)
	    
(*let string_of_scores scores =
  scores.(0).(0)
  
let print_scores req =
  let scores = scores 0 in
  App.respond' (`String (string_of_scores scores))*)
  
let _ =
  try
    let c = connect () in
    let req = "CREATE TABLE IF NOT EXISTS my_table (
	       user varchar NOT NULL,
	       password varchar NOT NULL,
	       problem integer NOT NULL,
	       score integer NOT NULL
	     )" in
    let res = c#exec req in
    App.empty
      |> post "/" print_json
      |> get "/" (print_hello res#error)
      |> App.run_command
  with
  | _ -> App.empty
	 |> post "/" print_json
	 |> get "/" (print_hello " people")
	 |> App.run_command
{'fraction_non_alphanumeric': 0.12607449856733524, 'fraction_numerical': 0.0028653295128939827, 'mean_word_length': 2.48585690515807, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 25, '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': '3148676', 'n_tokens_mistral': 745, 'n_tokens_neox': 692, 'n_words': 213}