added base html template
This commit is contained in:
parent
df08e944b9
commit
79273b2c0d
4 changed files with 25 additions and 23 deletions
5
main.go
5
main.go
|
@ -12,6 +12,7 @@ import (
|
|||
"gocv.io/x/gocv"
|
||||
)
|
||||
|
||||
var baseHTML = filepath.Join("templates", "base.html")
|
||||
var indexHTML = filepath.Join("templates", "index.html")
|
||||
var streamHTML = filepath.Join("templates", "stream.html")
|
||||
|
||||
|
@ -22,7 +23,7 @@ type Server struct {
|
|||
|
||||
func (server Server) index(w http.ResponseWriter, r *http.Request) {
|
||||
if r.FormValue("URL") == "" {
|
||||
indexTemplate, err := template.ParseFiles(indexHTML)
|
||||
indexTemplate, err := template.ParseFiles(indexHTML, baseHTML)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -36,7 +37,7 @@ func (server Server) index(w http.ResponseWriter, r *http.Request) {
|
|||
server.Streams[URL] = stream
|
||||
go stream.Update()
|
||||
}
|
||||
streamTemplate, err := template.ParseFiles(streamHTML)
|
||||
streamTemplate, err := template.ParseFiles(streamHTML, baseHTML)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
10
templates/base.html
Executable file
10
templates/base.html
Executable file
|
@ -0,0 +1,10 @@
|
|||
{{define "base"}}
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamWatcher</title>
|
||||
</head>
|
||||
<body>
|
||||
{{template "content" .}}
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
|
@ -1,11 +1,8 @@
|
|||
<html>
|
||||
<title>StreamWatcher</title>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<h1>Stream URL</h1>
|
||||
<form method="GET">
|
||||
<label>URL:</label>
|
||||
<input type="text" name="URL" size="100">
|
||||
</form>
|
||||
</html>
|
||||
{{template "base" .}}
|
||||
{{define "content"}}
|
||||
<h1>Stream URL</h1>
|
||||
<form method="GET">
|
||||
<label>URL:</label>
|
||||
<input type="text" name="URL" size="100">
|
||||
</form>
|
||||
{{end}}
|
|
@ -1,10 +1,4 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="/static/js/stream.js"></script>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<img src="/stream?URL={{.URL}}">
|
||||
</body>
|
||||
</html>
|
||||
{{template "base" .}}
|
||||
{{define "content"}}
|
||||
<img src="/stream?URL={{.URL}}">
|
||||
{{end}}
|
Loading…
Add table
Reference in a new issue