<commit_before>package main

import (
	"net/http"
	. "github.com/troy-work/whateversite/components"
	. "gopkg.in/tylerb/graceful.v1"
	"log"
	"time"
)

func redirectHttps(w http.ResponseWriter, req *http.Request) {
	log.Printf("redirecting to https")
	http.Redirect(w, req, "https://localhost:1443"+req.RequestURI, http.StatusMovedPermanently)
}


func main() {

	mux := http.NewServeMux()

	mux.HandleFunc("/", DefaultHandler)
	mux.HandleFunc("/view/", MakeHandler(ViewHandler))
	mux.HandleFunc("/edit/", MakeHandler(EditHandler))
	mux.HandleFunc("/save/", MakeHandler(SaveHandler))

	srvTls :=  &http.Server{
		Addr: ":1443",
		Handler: mux,
	}

	err := ListenAndServeTLS(srvTls, "cert/server.pem", "cert/server.key", time.Second)
	if (err != nil){
		log.Fatal("ListenAndServe", err)
	}

	mux2 := http.NewServeMux()
	mux2.Handle("*",http.HandlerFunc(redirectHttps))

	srv :=  &http.Server{
		Addr: ":1443",
		Handler: mux2,
	}

	//DON'T USE ListenAndServe like this. You can't shut it down
	ListenAndServe(srv, time.Second)

}<commit_msg>properly shuts down the servers;<commit_after>package main

import (
	"net/http"
	. "github.com/troy-work/whateversite/components"
	. "gopkg.in/tylerb/graceful.v1"
	"log"
)

func redirectHttps(w http.ResponseWriter, req *http.Request) {
	log.Printf("redirecting to https")
	http.Redirect(w, req, "https://localhost:1443"+req.RequestURI, http.StatusMovedPermanently)
}


func main() {

	go func() {
		mux := http.NewServeMux()

		mux.HandleFunc("/", DefaultHandler)
		mux.HandleFunc("/view/", MakeHandler(ViewHandler))
		mux.HandleFunc("/edit/", MakeHandler(EditHandler))
		mux.HandleFunc("/save/", MakeHandler(SaveHandler))

		srvTls := &Server{
			Timeout: 1,
			Server:  &http.Server{Addr: ":1443", Handler: mux},
		}
		err := srvTls.ListenAndServeTLS("cert/server.pem", "cert/server.key")

		if (err != nil) {
			log.Fatal("Tls", err)
		}
	}()

	srv := &Server{
		Timeout: 1,
		Server:  &http.Server{Addr: ":8080", Handler: http.HandlerFunc(redirectHttps)},
	}
	err := srv.ListenAndServe()
	if (err != nil){
		log.Fatal("http", err)
	}

}
{'fraction_non_alphanumeric': 0.17740384615384616, 'fraction_numerical': 0.014903846153846155, 'mean_word_length': 4.564171122994653, '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': '7502984', 'n_tokens_mistral': 868, 'n_tokens_neox': 806, 'n_words': 139}