From 570627183e7fb216c3b3eee1e667187841466a58 Mon Sep 17 00:00:00 2001 From: raul Date: Mon, 6 May 2024 08:52:48 +0200 Subject: [PATCH] Add basic functionality --- main.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.go b/main.go index 11f8ceb..2094dad 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,10 @@ package main import ( "fmt" + "log" + "net/http" + "github.com/bitfield/script" "github.com/gin-gonic/gin" ) @@ -21,5 +24,18 @@ func main() { } func sendCommand(c *gin.Context) { + var err error + cmd := c.Param("id") + newCMD := Shell{} + newCMD.Command = cmd + newCMD.Output, err = script.ListFiles(".").String() + if err != nil { + log.Printf("Error occurred with command: %v\n", err) + } + c.String(http.StatusOK, newCMD.Output) + // c.IndentedJSON(http.StatusOK, newCMD) + // c.HTML(http.StatusOK, newCMD) + fmt.Printf("The command \"%s\" has been called\n", cmd) + script.ListFiles(".").Stdout() }