added global vars for templates
This commit is contained in:
parent
69d30587cb
commit
df08e944b9
2 changed files with 9 additions and 2 deletions
7
main.go
7
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)
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<html>
|
||||
<title>StreamWatcher</title>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<h1>Stream URL</h1>
|
||||
<form method="GET">
|
||||
<label>URL:</label>
|
||||
|
|
Loading…
Add table
Reference in a new issue