1
0
forked from crony/UpFast
UpFast/main.go

41 lines
685 B
Go
Raw Normal View History

2023-12-19 13:22:13 +01:00
package main
import (
2023-12-19 19:59:53 +01:00
"html/template"
"io"
"net/http"
2023-12-19 19:59:53 +01:00
"github.com/labstack/echo/v4"
)
2023-12-19 13:22:13 +01:00
2023-12-19 19:59:53 +01:00
func main() {
t := &Template{
templates: template.Must(template.ParseGlob("public/views/*.html")),
}
e := echo.New()
e.Renderer = t
2023-12-19 20:50:26 +01:00
e.Static("/", "static")
2023-12-19 19:59:53 +01:00
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,
})
2023-12-19 13:22:13 +01:00
}