Same as last

This commit is contained in:
mStar aka a person 2024-01-08 16:58:43 +01:00
parent 09d000a1d5
commit 7270bd057e
3 changed files with 6 additions and 14 deletions

View file

@ -6,23 +6,12 @@ import (
"time" "time"
) )
var index_template *template.Template
type indexData struct { type indexData struct {
Time string Time string
} }
func handleRoot(w http.ResponseWriter, r *http.Request) { func handleRoot(w http.ResponseWriter, r *http.Request) {
//if index_template == nil { tmpl, err := template.ParseFS(embed_templates, "templates/index.html")
// tmpl, err := template.ParseFiles("templates/index.html")
// if err != nil {
// http.Error(w, "Couldn't parse template file", http.StatusInternalServerError)
// return
// }
// index_template = tmpl
//}
tmpl, err := template.ParseFiles("templates/index.html")
if err != nil { if err != nil {
http.Error(w, "Couldn't parse template file", http.StatusInternalServerError) http.Error(w, "Couldn't parse template file", http.StatusInternalServerError)
return return

View file

@ -1,11 +1,15 @@
package main package main
import ( import (
"embed"
"log" "log"
"net/http" "net/http"
"os" "os"
) )
//go:embed templates
var embed_templates embed.FS
func main() { func main() {
port := os.Getenv("PORT") port := os.Getenv("PORT")
if port == "" { if port == "" {
@ -14,9 +18,7 @@ func main() {
} }
http.HandleFunc("/", handleRoot) http.HandleFunc("/", handleRoot)
http.HandleFunc("/clicked", handleClicked)
if err := http.ListenAndServe(":"+port, nil); err != nil { if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }

View file

@ -6,6 +6,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Title</title> <title>Title</title>
<style> <style>
@import url('https://fonts.googleapis.com/css2?family=Cantarell&display=swap');
* { * {
font-family: Cantarell, sans-serif; font-family: Cantarell, sans-serif;
} }