<commit_before>'use strict'

const http = require('http');
const url = require('url');
const querystring = require('querystring');

const HOSTNAME = 'localhost';
const PORT = 4000;

let database = {};

function addToDatabase(obj) {
  database = Object.assign(database, obj);
  return Promise.resolve();
}

function getFromDatabase(key) {
  return Promise.resolve(database[key]);
}

function requestHandler(req) {
  // Checks the route (get or set) and returns a promise to do the operation
  // The promise returns a response object that can be serialised into JSON
  let parsedURL = url.parse(req.url);
  let parsedQuery = querystring.parse(parsedURL.query);
  let response = {status: 200, body: {success: true}};
  if (parsedURL.pathname === '/set') {
    return addToDatabase(parsedQuery);
  } else if (parsedURL.pathname === '/get') {
    return getFromDatabase(parsedQuery.key);
  } else {<commit_msg>remove comment that talked about returning json (only doing single value for now)<commit_after>'use strict'

const http = require('http');
const url = require('url');
const querystring = require('querystring');

const HOSTNAME = 'localhost';
const PORT = 4000;

let database = {};

function addToDatabase(obj) {
  database = Object.assign(database, obj);
  return Promise.resolve();
}

function getFromDatabase(key) {
  return Promise.resolve(database[key]);
}

function requestHandler(req) {
  // Checks the route (get or set) and returns a promise to do the operation
  let parsedURL = url.parse(req.url);
  let parsedQuery = querystring.parse(parsedURL.query);
  let response = {status: 200, body: {success: true}};
  if (parsedURL.pathname === '/set') {
    return addToDatabase(parsedQuery);
  } else if (parsedURL.pathname === '/get') {
    return getFromDatabase(parsedQuery.key);
  } else {
{'fraction_non_alphanumeric': 0.13082039911308205, 'fraction_numerical': 0.007760532150776054, 'mean_word_length': 4.748407643312102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '386459', 'n_tokens_mistral': 547, 'n_tokens_neox': 535, 'n_words': 166}