RunCode.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package controllers
  2. import (
  3. "Yunlot/RunCode/ctl"
  4. "Yunlot/conf"
  5. "Yunlot/lib"
  6. "Yunlot/logs"
  7. "fmt"
  8. beego "github.com/beego/beego/v2/server/web"
  9. )
  10. type RuncodeController struct {
  11. beego.Controller
  12. }
  13. func (c *RuncodeController) Languages() {
  14. ctl.LanguagesController(c.Ctx.ResponseWriter, c.Ctx.Request)
  15. }
  16. func (c *RuncodeController) Run() {
  17. ctl.RunController(c.Ctx.ResponseWriter, c.Ctx.Request)
  18. }
  19. func (c *RuncodeController) Build() {
  20. ctl.BuildController(c.Ctx.Output, c.Ctx.ResponseWriter, c.Ctx.Request)
  21. }
  22. func (c *RuncodeController) Download() {
  23. T_describe, err := c.GetInt("T_describe")
  24. if err != nil {
  25. c.Data["json"] = lib.JSONR{Code: lib.Error, Msg: "T_describe!"}
  26. c.ServeJSON()
  27. return
  28. }
  29. if T_describe <= 0 {
  30. c.Data["json"] = lib.JSONR{Code: lib.Error, Msg: "T_describe!"}
  31. c.ServeJSON()
  32. return
  33. }
  34. filePath := conf.Analysis_Dir + fmt.Sprintf("%d.so", T_describe) // 替换为实际的文件路径
  35. logs.Println("filePath:", filePath)
  36. c.Ctx.Output.Download(filePath, fmt.Sprintf("%d.so", T_describe))
  37. return
  38. }