package main import ( "errors" "fmt" "log" "os" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" ) func main() { _, err := os.Stat("storage") if errors.Is(err, os.ErrNotExist) { err2 := os.Mkdir("storage", 0775) if err2 != nil { log.Panic(map[string]error{ "err": err2, "cause": err, }) } } E := echo.New() E.Use(middleware.CORS()) E.GET("/", MainHandle) // / (Mostly version info, lists valid dirs) E.GET("/dir", GetDirHandle) // /dir?q= (lists dirs and files in absolute path) E.POST("/up", UploadJData) // /up?q= (Request.Body is saved into file) E.PUT("/up", UploadJData) // /up?q= (Request.Body is saved into file) E.GET("/down", DownloadJData) // /down?q= (Obtains the json data of the file) // Just prints out the paths r := E.Routes() for _, ro := range r { fmt.Printf("%-5s http://127.0.0.1:9000%s\n", ro.Method, ro.Path) } err = E.Start("0.0.0.0:9000") if err != nil { log.Panic(err) } }