Add basic functionality
This commit is contained in:
parent
517ce16690
commit
570627183e
16
main.go
16
main.go
|
@ -2,7 +2,10 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/bitfield/script"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,5 +24,18 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendCommand(c *gin.Context) {
|
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()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue