コード例 #1
0
func (this *ProblemController) Test() {
	pid := 1
	problem := models.Problem{Pid: pid}
	problem.GetByPid()
	code := this.GetString("code")
	lang := this.GetString("language")
	stdin := this.GetString("stdin")
	output := models.Exec(pid, code, lang, stdin)
	js, _ := json.Marshal(output)
	this.Data["json"] = string(js)
	this.ServeJson()
}
コード例 #2
0
func (this *ProblemController) RunCode() {
	if !this.isLoggedIn() {
		this.Redirect("/user/login", 302)
		return
	}

	//uid := this.GetSession("id")
	pid, _ := strconv.Atoi(this.Ctx.Input.Param(":id"))
	problem := models.Problem{Pid: pid}
	problem.GetByPid()
	code := this.GetString("code")
	lang := this.GetString("language")
	stdin := this.GetString("stdin")
	output := models.Exec(pid, code, lang, stdin)
	js, _ := json.Marshal(output)
	this.Data["json"] = string(js)
	this.ServeJson()
}