12345678910111213141516171819202122 |
- package controller
- import (
- "github.com/gin-gonic/gin"
- "github.com/langgenius/dify-sandbox/internal/service"
- "github.com/langgenius/dify-sandbox/internal/types"
- )
- func RunSandboxController(c *gin.Context) {
- BindRequest(c, func(req struct {
- Language string `json:"language" form:"language" binding:"required"`
- Code string `json:"code" form:"code" binding:"required"`
- }) {
- switch req.Language {
- case "python3":
- c.JSON(200, service.RunPython3Code(req.Code))
- default:
- c.JSON(400, types.ErrorResponse(-400, "unsupported language"))
- }
- })
- }
|