From df08e944b904befd8be73650d2bf625689e73949 Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Thu, 9 Jul 2020 19:13:28 +0000 Subject: [PATCH] added global vars for templates --- main.go | 7 +++++-- templates/index.html | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 7616ae3..84d0c41 100755 --- a/main.go +++ b/main.go @@ -12,6 +12,9 @@ import ( "gocv.io/x/gocv" ) +var indexHTML = filepath.Join("templates", "index.html") +var streamHTML = filepath.Join("templates", "stream.html") + // Server is the main application struct type Server struct { Streams map[string]Stream @@ -19,7 +22,7 @@ type Server struct { func (server Server) index(w http.ResponseWriter, r *http.Request) { if r.FormValue("URL") == "" { - indexTemplate, err := template.ParseFiles(filepath.Join("templates", "index.html")) + indexTemplate, err := template.ParseFiles(indexHTML) if err != nil { log.Fatal(err) } @@ -33,7 +36,7 @@ func (server Server) index(w http.ResponseWriter, r *http.Request) { server.Streams[URL] = stream go stream.Update() } - streamTemplate, err := template.ParseFiles(filepath.Join("templates", "stream.html")) + streamTemplate, err := template.ParseFiles(streamHTML) if err != nil { log.Fatal(err) diff --git a/templates/index.html b/templates/index.html index f6fe63a..0f57dc9 100755 --- a/templates/index.html +++ b/templates/index.html @@ -1,4 +1,8 @@ + StreamWatcher + + +

Stream URL