Files
crawlab/backend/routes/file.go
2019-07-24 13:37:03 +08:00

21 lines
360 B
Go

package routes
import (
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
)
func GetFile(c *gin.Context) {
path := c.Query("path")
fileBytes, err := ioutil.ReadFile(path)
if err != nil {
HandleError(http.StatusInternalServerError, c, err)
}
c.JSON(http.StatusOK, Response{
Status: "ok",
Message: "success",
Data: string(fileBytes),
})
}