<commit_before>package main

//go:generate appcfg.py update .

import (
	"net/http"
	"runtime/debug"
	"time"

	"golang.org/x/net/context"

	"google.golang.org/appengine"
	"google.golang.org/appengine/datastore"
	"google.golang.org/appengine/log"
)

func init() {
	http.HandleFunc("/", route)
}

func main() {
	appengine.Main()
}

func route(w http.ResponseWriter, r *http.Request) {
	ctx := appengine.NewContext(r)
	start := time.Now()
	defer func() {
		if re := recover(); re != nil {
			log.Criticalf(ctx, "Problem: %#v %s", re, debug.Stack())
			http.Error(w, "FAIL WHALE!", http.StatusInternalServerError)
		} else {
			log.Debugf(ctx, "%s %s: %s", r.Method, r.URL, time.Since(start))
		}
	}()
	// TODO: OPTIONS
	w.Header().Add("X-Clacks-Overhead", "GNU Terry Pratchett")
	switch r.Method {
	case "GET":
		index(ctx, w, r)
	case "POST":
		upload(ctx, w, r)
	default:
		// Technically http.StatusMethodNotAllowed, but less visible errors
		http.Redirect(w, r, "/", http.StatusSeeOther)
	}
}

func path2key(ctx context.Context, path string) (key *datastore.Key) {
	if path != "" {
		key = datastore.NewKey(ctx, "Path", path, 0, nil)
	}<commit_msg>Adding appstats to appengine<commit_after>package main

//go:generate appcfg.py update .

import (
	"net/http"
	"runtime/debug"
	"time"

	"github.com/mjibson/appstats"

	"golang.org/x/net/context"

	"google.golang.org/appengine"
	"google.golang.org/appengine/datastore"
	"google.golang.org/appengine/log"
)

func init() {
	http.Handle("/", appstats.NewHandler(route))
}

func main() {
	appengine.Main()
}

func route(ctx context.Context, w http.ResponseWriter, r *http.Request) {
	start := time.Now()
	defer func() {
		if re := recover(); re != nil {
			log.Criticalf(ctx, "Problem: %#v %s", re, debug.Stack())
			http.Error(w, "FAIL WHALE!", http.StatusInternalServerError)
		} else {
			log.Debugf(ctx, "%s %s: %s", r.Method, r.URL, time.Since(start))
		}
	}()
	// TODO: OPTIONS
	w.Header().Add("X-Clacks-Overhead", "<NAME>")
	switch r.Method {
	case "GET":
		index(ctx, w, r)
	case "POST":
		upload(ctx, w, r)
	default:
		// Technically http.StatusMethodNotAllowed, but less visible errors
		http.Redirect(w, r, "/", http.StatusSeeOther)
	}
}

func path2key(ctx context.Context, path string) (key *datastore.Key) {
	if path != "" {
		key = datastore.NewKey(ctx, "Path", path, 0, nil)
	}
{'fraction_non_alphanumeric': 0.1817792985457656, 'fraction_numerical': 0.001710863986313088, 'mean_word_length': 3.9450317124735728, 'pattern_counts': {'":': 4, '<': 4, '<?xml version=': 0, '>': 4, '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': '1937833', 'n_tokens_mistral': 971, 'n_tokens_neox': 909, 'n_words': 196}