Пример #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)
	mainRun(runner)
}
Пример #2
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)
	}
}
Пример #3
0
func main() {
	var pathToRunner string
	flag.StringVar(&pathToRunner, "runner", os.Getenv("RUNNER_BINARY"), "path to runner binary")
	flag.Parse()
	runner := code.NewRunner(pathToRunner)

	fb := firego.New("https://thinkhike.firebaseio.com/problems", nil)
	problems := map[string]string{}

	if err := fb.Value(&problems); err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s\n", problems)
	if runner != nil && false {
	}
	ec := code.GistFetch(problems["prob-1"])
	fmt.Printf("%#v", ec)
}
Пример #4
0
func main() {
	flag.Parse()
	initialize()

	runner := code.NewRunner(*RUNNER)
	e := echo.New()
	e.Use(mw.Logger())
	e.Static("/", filepath.Join(*ROOT, "static"))
	e.Index(filepath.Join(*ROOT, "static/index.html"))
	e.Post("/run", func(c *echo.Context) error {
		input := &code.Input{}
		err := decodeJsonPayload(c.Request(), input)
		if err != nil {
			return err
		}
		output, err := runner.Run(input)
		if err != nil {
			return err
		}
		return c.JSON(http.StatusOK, output)
	})
	e.Run(fmt.Sprintf(":%s", *PORT))
}
Пример #5
0
func main() {
	port := os.Getenv("PORT")
	if port == "" {
		port = "8085"
	}

	var pathToRunner string
	flag.StringVar(&pathToRunner, "runner", os.Getenv("RUNNER_BINARY"), "path to runner binary")
	flag.Parse()
	runner = code.NewRunner(pathToRunner)
	log.Printf("In main, Runner: %v", runner)

	mymap = make(map[string][]byte)
	mymap["correct"] = []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="104" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="104" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#4c1" d="M54 0h50v20H54z"/><path fill="url(#b)" d="M0 0h104v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="78" y="15" fill="#010101" fill-opacity=".3">correct</text><text x="78" y="14">correct</text></g></svg>`)
	mymap["wrong"] = []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="99" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#e05d44" d="M54 0h45v20H54z"/><path fill="url(#b)" d="M0 0h99v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="75.5" y="15" fill="#010101" fill-opacity=".3">wrong</text><text x="75.5" y="14">wrong</text></g></svg>`)

	mux := http.NewServeMux()
	mux.HandleFunc("/", IndexHandler)
	mux.HandleFunc("/view", ViewHandler)
	mux.HandleFunc("/result/", resultHandler)
	log.Printf("Server started. Listening on %s...", port)
	http.ListenAndServe(fmt.Sprintf(":%s", port), mux)

}