Add basic functionality

This commit is contained in:
raul 2024-05-06 08:52:48 +02:00
parent 517ce16690
commit 570627183e
1 changed files with 16 additions and 0 deletions

16
main.go
View File

@ -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()
}