From bad67d2a6806b37752c3ec9e3220575618e71234 Mon Sep 17 00:00:00 2001 From: CronyAkatsuki Date: Tue, 19 Dec 2023 21:01:30 +0100 Subject: [PATCH] Server future uploaded files. --- .gitignore | 1 + main.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 117a251..ec996f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ upload env .env +files diff --git a/main.go b/main.go index 5e9ea03..e034d48 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,12 @@ package main import ( + "errors" "html/template" "io" + "log" "net/http" + "os" "github.com/labstack/echo/v4" ) @@ -19,6 +22,17 @@ func main() { e.Static("/", "static") + files := "files" + + if _, err := os.Stat(files); errors.Is(err, os.ErrNotExist) { + err := os.Mkdir(files, os.ModePerm) + if err != nil { + log.Println(err) + } + } + + e.Static("/files", files) + e.GET("/", Index) e.Logger.Fatal(e.Start(":1323"))