Server future uploaded files.

This commit is contained in:
CronyAkatsuki 2023-12-19 21:01:30 +01:00
parent 6dda92caec
commit bad67d2a68
2 changed files with 15 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
upload upload
env env
.env .env
files

14
main.go
View File

@ -1,9 +1,12 @@
package main package main
import ( import (
"errors"
"html/template" "html/template"
"io" "io"
"log"
"net/http" "net/http"
"os"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )
@ -19,6 +22,17 @@ func main() {
e.Static("/", "static") 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.GET("/", Index)
e.Logger.Fatal(e.Start(":1323")) e.Logger.Fatal(e.Start(":1323"))