[WIP] settings up template and static files embedding

This commit is contained in:
HeshamTB 2023-09-11 20:54:28 +03:00
parent 598fd51412
commit 5c7bfc21ed
4 changed files with 22 additions and 1 deletions

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module gitea.hbanafa.com/hesham/viddl
go 1.21.0

11
main.go
View File

@ -1,6 +1,7 @@
package main
import (
"embed"
"encoding/json"
"fmt"
"html/template"
@ -8,6 +9,8 @@ import (
"log"
"net/http"
"time"
"gitea.hbanafa.com/hesham/viddl/resources"
)
const (
@ -77,6 +80,14 @@ func writeJSONResponse(w http.ResponseWriter, s string) http.ResponseWriter {
}
var templates *template.Template
func init() {
log.Println("[ init ] Starting...")
templates = template.Must(template.ParseFS(resources.TemplatesFS, "templates/*.html"))
}
func main() {
handler := http.NewServeMux()

7
resources/resources.go Normal file
View File

@ -0,0 +1,7 @@
package resources
import "embed"
//go:embed gitea.hbanafa.com/hesham/viddl/resources
var TemplatesFS embed.FS

View File

@ -1 +1 @@
<a href="{{ . }}" rel="nofollow" download>Download</a>
<a href="{{ . }}" rel="" download target="_blank">Download</a>