<commit_before>package org.cri.redmetrics;

import com.google.gson.JsonSyntaxException;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.cri.redmetrics.controller.*;
import org.cri.redmetrics.dao.DbException;
import org.cri.redmetrics.dao.InconsistentDataException;
import org.cri.redmetrics.guice.MainModule;
import spark.Request;
import spark.Response;

import java.sql.SQLException;
import org.cri.redmetrics.db.Db;

import static spark.Spark.*;

public class Server {

    public static String hostName;

    private static void enableCORS(final String origin, final String methods, final String headers) {
        before((Request request, Response response) -> {
            response.header("Access-Control-Allow-Origin", origin);
            response.header("Access-Control-Allow-Methods", methods);
            response.header("Access-Control-Allow-Headers", headers);
        });
    }


    private final int portNumber;
    private final Db database;

    private boolean started;

    public Server(int portNumber, Db database) {
        this.portNumber = portNumber;
        this.database = database;
    }
    
    public int getPort(){
        return portNumber;
    }

    public void start() {

        if (started) return;
        started = true;

        setPort(portNumber);

        enableCORS("*", "GET, POST, PUT, DELETE, OPTIONS", "Content-Type");

        Injector injector = Guice.createInjector(new MainModule(database));<commit_msg>Expose custom headers<commit_after>package org.cri.redmetrics;

import com.google.gson.JsonSyntaxException;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.cri.redmetrics.controller.*;
import org.cri.redmetrics.dao.DbException;
import org.cri.redmetrics.dao.InconsistentDataException;
import org.cri.redmetrics.guice.MainModule;
import spark.Request;
import spark.Response;

import java.sql.SQLException;
import org.cri.redmetrics.db.Db;

import static spark.Spark.*;

public class Server {

    public static String hostName;

    private static void enableCORS() {
        before((Request request, Response response) -> {
            response.header("Access-Control-Allow-Origin", "*");
            response.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
            response.header("Access-Control-Allow-Headers", "Content-Type");
            response.header("Access-Control-Expose-Headers", "Content-Type, Location, Link, X-Total-Count");
        });
    }


    private final int portNumber;
    private final Db database;

    private boolean started;

    public Server(int portNumber, Db database) {
        this.portNumber = portNumber;
        this.database = database;
    }
    
    public int getPort(){
        return portNumber;
    }

    public void start() {

        if (started) return;
        started = true;

        setPort(portNumber);

        enableCORS();

        Injector injector = Guice.createInjector(new MainModule(database));
{'fraction_non_alphanumeric': 0.10911510312707917, 'fraction_numerical': 0.0, 'mean_word_length': 3.217391304347826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1551761', 'n_tokens_mistral': 858, 'n_tokens_neox': 843, 'n_words': 197}