Initial Commit
This commit is contained in:
32
handlers.go
Normal file
32
handlers.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func index(c *gin.Context) {
|
||||
index_page, err := indexHTML.ReadFile("html/index.html")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c.Data(http.StatusOK, "text/html", index_page)
|
||||
}
|
||||
|
||||
func update(c *gin.Context) {
|
||||
cmd := exec.Command("awdaawdawd")
|
||||
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
|
||||
err := cmd.Run()
|
||||
|
||||
if err != nil {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
c.String(http.StatusOK, out.String())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user