<commit_before>import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;

import static spark.Spark.*;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.philihp.weblabora.model.*;
import org.apache.commons.codec.binary.Hex;

public class Main {

  private static ObjectMapper objectMapper = new ObjectMapper();

  private static Cache<String, String> cache =
      CacheBuilder.newBuilder()
          .maximumSize(100000)
          .expireAfterAccess(7, TimeUnit.DAYS)
          .build();

  public static void main(String[] args) {

    port(Integer.valueOf(System.getenv("PORT")));

    get("/:hash", "application/json", (request, response) -> {
      String hash = request.params(":hash");
      return cache.get(hash, () -> {
        response.status(404);
        return "{\"error\":\"Forgot state of board. Please retry.\"}";
      });
    });

    get("/", "application/json", (request, response) -> {;
      return Boolean.FALSE;
    });

    put("/", "application/json", (request, response) -> {
      String hash = hash(request.body());
      Board board = new Board();
      String[] tokens = request.body().split("\n+");
      for (String token : tokens) {
        MoveProcessor.processMove(board, token);
      }
      cache.put(hash, objectMapper.valueToTree(board).toString());
      response.redirect("/" + hash, 303); // very important to use 303
      return null;
    });

    options("/*", (request, response) -> {
      return "OK";
    });

    before((request,response)-> {
      String origin = request.headers("Origin");
      if(origin != null) {
        response.header("Access-Control-Allow-Origin", origin);
      }
      String headers = request.headers("Access-Control-Request-Headers");
      if (headers != null) {
        response.header("Access-Control-Allow-Headers", headers);<commit_msg>Change PUT to POST because ungh<commit_after>import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;

import static spark.Spark.*;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.philihp.weblabora.model.*;
import org.apache.commons.codec.binary.Hex;

public class Main {

  private static ObjectMapper objectMapper = new ObjectMapper();

  private static Cache<String, String> cache =
      CacheBuilder.newBuilder()
          .maximumSize(100000)
          .expireAfterAccess(7, TimeUnit.DAYS)
          .build();

  public static void main(String[] args) {

    port(Integer.valueOf(System.getenv("PORT")));

    get("/:hash", "application/json", (request, response) -> {
      String hash = request.params(":hash");
      return cache.get(hash, () -> {
        response.status(404);
        return "{\"error\":\"Forgot state of board. Please retry.\"}";
      });
    });

    get("/", "application/json", (request, response) -> {;
      return Boolean.FALSE;
    });

    post("/", "application/json", (request, response) -> {
      String hash = hash(request.body());
      Board board = new Board();
      String[] tokens = request.body().split("\n+");
      for (String token : tokens) {
        MoveProcessor.processMove(board, token);
      }
      cache.put(hash, objectMapper.valueToTree(board).toString());
      response.redirect("/" + hash, 303); // very important to use 303
      return null;
    });

    options("/*", (request, response) -> {
      return "OK";
    });

    before((request,response)-> {
      String origin = request.headers("Origin");
      if(origin != null) {
        response.header("Access-Control-Allow-Origin", origin);
      }
      String headers = request.headers("Access-Control-Request-Headers");
      if (headers != null) {
        response.header("Access-Control-Allow-Headers", headers);
{'fraction_non_alphanumeric': 0.1565086531226486, 'fraction_numerical': 0.00802608477552044, 'mean_word_length': 3.102880658436214, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6504342', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1107, 'n_words': 244}