Beispiel #1
0
func main() {
	var pathToRunner string
	flag.StringVar(&pathToRunner, "runner", os.Getenv("RUNNER_BINARY"), "path to runner binary")
	flag.Parse()
	runner := code.NewRunner(pathToRunner)
	id := "4f1bae999b5fbea43624"
	if len(flag.Args()) > 0 {
		id = flag.Args()[0]
	}
	if runner != nil && false {
		fmt.Printf("%s", code.GistEvaluate(id, runner))
	} else {
		evalContext := code.GistFetch(id)
		fmt.Printf("%s", evalContext)
	}
}
Beispiel #2
0
func resultHandler(w http.ResponseWriter, r *http.Request) {
	id := r.URL.String()[len("/result/"):]
	log.Printf("Got Gist Id: %s", id)
	result := code.GistEvaluate(id, runner)
	state = result.Correct

	date := time.Now().Format(http.TimeFormat)
	log.Printf("%v", date)
	log.Printf("State %v", state)
	w.Header().Set("Content-Type", "image/svg+xml")
	w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
	w.Header().Set("Date", date)
	w.Header().Set("Expires", date)
	if state {
		w.Write(mymap["correct"])
	} else {
		w.Write(mymap["wrong"])
	}
}