<commit_before>// The following line is needed for generating go code from templates
// with `go generate`.
// See https://blog.golang.org/generate for more info.
// Quicktemplate compiler (qtc) must be installed before running
// `go generate`:
//
//     go get -u github.com/valyala/quicktemplate/qtc
//
//go:generate qtc
package main

import (
	"fmt"
	"log"
	"math/rand"

	"github.com/valyala/fasthttp"

	"./templates"
)

func main() {
	log.Printf("starting the server at http://localhost:8080 ...")
	err := fasthttp.ListenAndServe("localhost:8080", requestHandler)
	if err != nil {
		log.Fatalf("unexpected error in server: %s", err)
	}
}

func requestHandler(ctx *fasthttp.RequestCtx) {
	switch string(ctx.Path()) {
	case "/":
		mainPageHandler(ctx)
	case "/table":
		tablePageHandler(ctx)
	default:
		errorPageHandler(ctx)
	}
	ctx.SetContentType("text/html; charset=utf-8")
}

func mainPageHandler(ctx *fasthttp.RequestCtx) {
	p := &templates.MainPage{
		CTX: ctx,
	}
	templates.WritePage(ctx, p)
}

func tablePageHandler(ctx *fasthttp.RequestCtx) {
	rowsCount := ctx.QueryArgs().GetUintOrZero("rowsCount")<commit_msg>use absolute path to example templates, since go get quicktemplate/... fails otherwise with 'local import in non-local package'<commit_after>// The following line is needed for generating go code from templates
// with `go generate`.
// See https://blog.golang.org/generate for more info.
// Quicktemplate compiler (qtc) must be installed before running
// `go generate`:
//
//     go get -u github.com/valyala/quicktemplate/qtc
//
//go:generate qtc
package main

import (
	"fmt"
	"log"
	"math/rand"

	"github.com/valyala/fasthttp"

	"github.com/valyala/quicktemplate/examples/basic/templates"
)

func main() {
	log.Printf("starting the server at http://localhost:8080 ...")
	err := fasthttp.ListenAndServe("localhost:8080", requestHandler)
	if err != nil {
		log.Fatalf("unexpected error in server: %s", err)
	}
}

func requestHandler(ctx *fasthttp.RequestCtx) {
	switch string(ctx.Path()) {
	case "/":
		mainPageHandler(ctx)
	case "/table":
		tablePageHandler(ctx)
	default:
		errorPageHandler(ctx)
	}
	ctx.SetContentType("text/html; charset=utf-8")
}

func mainPageHandler(ctx *fasthttp.RequestCtx) {
	p := &templates.MainPage{
		CTX: ctx,
	}
	templates.WritePage(ctx, p)
}

func tablePageHandler(ctx *fasthttp.RequestCtx) {
	rowsCount := ctx.QueryArgs().GetUintOrZero("rowsCount")
{'fraction_non_alphanumeric': 0.143687707641196, 'fraction_numerical': 0.007475083056478406, 'mean_word_length': 4.294505494505494, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4189480', 'n_tokens_mistral': 853, 'n_tokens_neox': 809, 'n_words': 198}