From cd4592d25785a7b0317b68ba32815d1353c62e62 Mon Sep 17 00:00:00 2001 From: CronyAkatsuki Date: Tue, 19 Dec 2023 19:59:53 +0100 Subject: [PATCH] Add basic index page. --- main.go | 39 +++++++++++++++++++++++------ public/views/index.html | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 public/views/index.html diff --git a/main.go b/main.go index 95b5330..d2e69ea 100644 --- a/main.go +++ b/main.go @@ -1,15 +1,38 @@ package main import ( - "net/http" + "html/template" + "io" + "net/http" - "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4" ) -func main() { - e := echo.New() - e.GET("/", func(c echo.Context) error { - return c.String(http.StatusOK, "Hello, World!") - }) - e.Logger.Fatal(e.Start(":1323")) +func main() { + t := &Template{ + templates: template.Must(template.ParseGlob("public/views/*.html")), + } + + e := echo.New() + + e.Renderer = t + + e.GET("/", Index) + + e.Logger.Fatal(e.Start(":1323")) +} + +type Template struct { + templates *template.Template +} + +func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error { + return t.templates.ExecuteTemplate(w, name, data) +} + +func Index(c echo.Context) error { + return c.Render(http.StatusOK, "index", map[string]interface{}{ + "host": c.Request().Host, + "upload_only": true, + }) } diff --git a/public/views/index.html b/public/views/index.html new file mode 100644 index 0000000..373d139 --- /dev/null +++ b/public/views/index.html @@ -0,0 +1,54 @@ +{{define "index"}} + + + + + UpFast + + + + + + +

UpFast: Minimal file upload and sharing tool

+ +

+ 0x0.st Influenced file upload and sharing + tool +

+ +

+ To upload files use curl: + curl -F "file=@/path/to/file" "{{index . "host"}}" +

+ +

+ To delete a file using curl: + curl "{{index . "host"}}/delete/file_name" +

+ + {{if index . "upload_only"}} +

+ NOTE: This is an upload only instance, if you wan't a file on the instance + deleted ask the hoster to delete the file. +

+ {{end}} + +

+ To get of all files hosted on the instance check + files +

+ +

+ Created and maintained by + Crony Akatsuki +

+ +

+ Code is hosted on + https://code.cronyakatsuki.xyz/crony/upfast +

+ + + +{{end}}