Skip to content
Snippets Groups Projects
Commit 2e4d8be4 authored by gbe's avatar gbe
Browse files

Add skeleton

parent cd0223f1
No related branches found
No related tags found
No related merge requests found
module git.c3pb.de/gbe/invinoveritas
go 1.15
go 1.16
main.go 0 → 100644
package main
import (
"embed"
"html/template"
"log"
"net/http"
)
//go:embed templates/*.tpl
var templateFS embed.FS
var templates = template.Must(template.ParseFS(templateFS, "templates/*.tpl"))
//go:embed static/*
var staticFS embed.FS
func main() {
http.Handle("/static/", http.FileServer(http.FS(staticFS)))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
log.Println("handling", r.Method, r.URL, "from", r.RemoteAddr)
if r.Method == "GET" {
w.Header().Add("content-type", "text/html")
err := templates.ExecuteTemplate(w, "index.tpl", nil)
if err != nil {
log.Println("can't execute index template:", err)
}
return
}
})
const listenAddr = "127.0.0.1:7878"
log.Printf("here we go, listening on http://%s", listenAddr)
err := http.ListenAndServe(listenAddr, nil)
if err != nil {
log.Println("http handler failed:", err)
}
}
Sun Apr 11 18:32:00 CES 2021
<!doctype html5>
<html>
<head>
<title>In Vino Veritas</title>
</head>
<body>
Here there be dragons.
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment