<commit_before>package web

import (
	"encoding/json"
	"log"
	"net/http"
)

type jsonError struct {
	Error string `json:"error"`
}

func handleError(w http.ResponseWriter, err error, msg string) {
	log.Printf("ERROR \"%s\": %+v", msg, err)

	writeJSON(w, 500, jsonError{Error: msg})
}

func writeJSON(w http.ResponseWriter, status int, content interface{}) {
	data, err := json.MarshalIndent(content, "", "  ")
	if err != nil {
		handleError(w, err, "Failed to create JSON output!")
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(201)
	w.Write(data)
}<commit_msg>Fix response status.<commit_after>package web

import (
	"encoding/json"
	"log"
	"net/http"
)

type jsonError struct {
	Error string `json:"error"`
}

func handleError(w http.ResponseWriter, err error, msg string) {
	log.Printf("ERROR \"%s\": %+v", msg, err)

	writeJSON(w, 500, jsonError{Error: msg})
}

func writeJSON(w http.ResponseWriter, status int, content interface{}) {
	data, err := json.MarshalIndent(content, "", "  ")
	if err != nil {
		handleError(w, err, "Failed to create JSON output!")
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(status)
	w.Write(data)
}
{'fraction_non_alphanumeric': 0.16722129783693843, 'fraction_numerical': 0.0074875207986688855, 'mean_word_length': 4.6745283018867925, 'pattern_counts': {'":': 2, '<': 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': '6908121', 'n_tokens_mistral': 443, 'n_tokens_neox': 427, 'n_words': 108}