aboutsummaryrefslogtreecommitdiff
path: root/watch.go
diff options
context:
space:
mode:
authorTim Keller <tjkeller.xyz>2025-05-24 12:52:32 -0500
committerTim Keller <tjkeller.xyz>2025-05-24 12:52:32 -0500
commitbcf66d92d664dd707937ae866830a6bee0751745 (patch)
tree5c1f7ecc037b53b434befe71509cc3009beaf3d7 /watch.go
parent6b0385c495b246859d27bfa75e1bd4dfa45c2be2 (diff)
downloadmintube-bcf66d92d664dd707937ae866830a6bee0751745.tar.xz
mintube-bcf66d92d664dd707937ae866830a6bee0751745.zip
cleanup all go code and add an index/home page that is composed from the readme fileHEADmaster
Diffstat (limited to 'watch.go')
-rw-r--r--watch.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/watch.go b/watch.go
new file mode 100644
index 0000000..8352e62
--- /dev/null
+++ b/watch.go
@@ -0,0 +1,34 @@
+package main
+
+import (
+ "html/template"
+ "net/http"
+)
+
+var templateWatchFiles = []string{ "templates/base.html", "templates/watch.html" }
+var templateWatch = template.Must(template.ParseFiles(templateWatchFiles...))
+
+/* render template */
+type WatchTemplateData struct {
+ Id string
+}
+
+func renderWatchTemplate(w http.ResponseWriter, id string) {
+ if debug {
+ reloadTemplate(&templateWatch, templateWatchFiles...)
+ }
+ err := templateWatch.Execute(w, WatchTemplateData{
+ Id: id,
+ })
+ if err != nil {
+ templateError(err, w)
+ }
+}
+
+/* routes */
+func setupRoutesWatch() {
+ http.HandleFunc("/watch", func(w http.ResponseWriter, r *http.Request) {
+ id := r.URL.Query().Get("v")
+ renderWatchTemplate(w, id)
+ })
+}