<commit_before>package main

import (
	"fmt"
	"net/http"
	"strconv"

	"github.com/zenazn/goji"
	"github.com/zenazn/goji/web"

	"github.com/flosch/pongo2"
)

type Page struct {
	Title              string
	CurrentTemperature float64
	TargetTemperature  float64
	IsHeating          string
}

func root(c web.C, w http.ResponseWriter, r *http.Request) {

	var page Page
	page.Title = "My Cooker"

	page.TargetTemperature = getTargetTemp()
	page.CurrentTemperature = getCurrentTemp()
	page.IsHeating = isHeating()

	tpl, err := pongo2.DefaultSet.FromFile("template.tpl")
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	tpl.ExecuteWriter(pongo2.Context{"page": page}, w)
}

func setTarget(c web.C, w http.ResponseWriter, r *http.Request) {
	target := c.URLParams["target"]
	fmt.Println(target)

	t, err := strconv.ParseFloat(target, 32)
	if err != nil || t < 0 || t > 100 {
		// Invalid format or out of correct range
		http.Redirect(w, r, "/", 400)
		return
	}

	fmt.Println("Set " + target)
	setTargetTemp(target)
	http.Redirect(w, r, "/", 200)
}

func main() {
	goji.Get("/", root)
	goji.Get("/set/:target", setTarget)
	goji.Serve()
}<commit_msg>avoid to show transition page<commit_after>package main

import (
	"fmt"
	"net/http"
	"strconv"

	"github.com/zenazn/goji"
	"github.com/zenazn/goji/web"

	"github.com/flosch/pongo2"
)

type Page struct {
	Title              string
	CurrentTemperature float64
	TargetTemperature  float64
	IsHeating          string
}

func root(c web.C, w http.ResponseWriter, r *http.Request) {

	var page Page
	page.Title = "My Cooker"

	page.TargetTemperature = getTargetTemp()
	page.CurrentTemperature = getCurrentTemp()
	page.IsHeating = isHeating()

	tpl, err := pongo2.DefaultSet.FromFile("template.tpl")
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	tpl.ExecuteWriter(pongo2.Context{"page": page}, w)
}

func setTarget(c web.C, w http.ResponseWriter, r *http.Request) {
	target := c.URLParams["target"]
	fmt.Println(target)

	t, err := strconv.ParseFloat(target, 32)
	if err != nil || t < 0 || t > 100 {
		// Invalid format or out of correct range
		http.Redirect(w, r, "/", 400)
		return
	}

	fmt.Println("Set " + target)
	setTargetTemp(target)
	http.Redirect(w, r, "/", http.StatusMovedPermanently)	// workaround to suppress transition page.
}

func forceOff(c web.C, w http.ResponseWriter, r *http.Request) {
	setTargetTemp("0.0")
	http.Redirect(w, r, "/", http.StatusMovedPermanently)
}

func forceOn(c web.C, w http.ResponseWriter, r *http.Request) {
	setTargetTemp("100.0")
	http.Redirect(w, r, "/", http.StatusMovedPermanently)
}

func main() {
	goji.Get("/", root)
	goji.Get("/set/:target", setTarget)
	goji.Get("/force_on", forceOn)
	goji.Get("/force_off", forceOff)
	goji.Serve()
}
{'fraction_non_alphanumeric': 0.15007112375533427, 'fraction_numerical': 0.014580369843527738, 'mean_word_length': 3.9437609841827768, 'pattern_counts': {'":': 2, '<': 5, '<?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': '6447027', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1054, 'n_words': 229}