<commit_before>package web

import (
	"html/template"
	"log"
	"net/http"

	"github.com/StackExchange/tsaf/search"
	"github.com/gorilla/mux"
)

var TSDBHttp string
var templates *template.Template
var router = mux.NewRouter()

func Listen(addr, dir, tsdbhttp string) error {
	TSDBHttp = tsdbhttp
	var err error
	templates, err = template.New("").ParseFiles(
		dir + "/templates/chart.html",
	)
	if err != nil {
		log.Fatal(err)
	}
	router.HandleFunc("/", Index)
	router.HandleFunc("/api/chart", Chart)
	router.HandleFunc("/api/metric", UniqueMetrics)
	router.HandleFunc("/api/metric/{tagk}/{tagv}", MetricsByTagPair)
	router.HandleFunc("/api/tagk/{metric}", TagKeysByMetric)
	router.HandleFunc("/api/tagv/{tagk}/{metric}", TagValuesByMetricTagKey)
	router.HandleFunc("/api/tagv/{tagk}", TagValuesByTagKey)
	http.Handle("/", router)
	http.Handle("/static/", http.FileServer(http.Dir(dir)))
	log.Println("web listening on", addr)
	return http.ListenAndServe(addr, nil)
}

func Index(w http.ResponseWriter, r *http.Request) {
	templates.ExecuteTemplate(w, "chart.html", struct {
		Metric, Tagv search.QMap
		Tagk         search.SMap
	}{
		search.Metric,
		search.Tagv,
		search.Tagk,
	})
}


<commit_msg>gofmt<commit_after>package web

import (
	"html/template"
	"log"
	"net/http"

	"github.com/StackExchange/tsaf/search"
	"github.com/gorilla/mux"
)

var TSDBHttp string
var templates *template.Template
var router = mux.NewRouter()

func Listen(addr, dir, tsdbhttp string) error {
	TSDBHttp = tsdbhttp
	var err error
	templates, err = template.New("").ParseFiles(
		dir + "/templates/chart.html",
	)
	if err != nil {
		log.Fatal(err)
	}
	router.HandleFunc("/", Index)
	router.HandleFunc("/api/chart", Chart)
	router.HandleFunc("/api/metric", UniqueMetrics)
	router.HandleFunc("/api/metric/{tagk}/{tagv}", MetricsByTagPair)
	router.HandleFunc("/api/tagk/{metric}", TagKeysByMetric)
	router.HandleFunc("/api/tagv/{tagk}/{metric}", TagValuesByMetricTagKey)
	router.HandleFunc("/api/tagv/{tagk}", TagValuesByTagKey)
	http.Handle("/", router)
	http.Handle("/static/", http.FileServer(http.Dir(dir)))
	log.Println("web listening on", addr)
	return http.ListenAndServe(addr, nil)
}

func Index(w http.ResponseWriter, r *http.Request) {
	templates.ExecuteTemplate(w, "chart.html", struct {
		Metric, Tagv search.QMap
		Tagk         search.SMap
	}{
		search.Metric,
		search.Tagv,
		search.Tagk,
	})
}
{'fraction_non_alphanumeric': 0.16241105064880704, 'fraction_numerical': 0.0, 'mean_word_length': 4.717703349282297, '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': '5271419', 'n_tokens_mistral': 884, 'n_tokens_neox': 862, 'n_words': 156}