This repository has been archived on 2021-01-15. You can view files and clone it, but cannot push or open issues or pull requests.
goBug/html.go

35 lines
820 B
Go
Raw Permalink Normal View History

2017-05-26 13:35:26 +00:00
package main
import (
"html/template"
"net/http"
)
2017-05-26 15:54:45 +00:00
var varmap map[string]interface{}
2017-05-26 13:35:26 +00:00
// ServiHTML fa partire il server html
func ServiHTML() {
2017-05-26 15:54:45 +00:00
varmap = map[string]interface{}{
2017-05-26 14:28:38 +00:00
"matrice": Matrix,
"tempoAggiorna": Clock,
2017-05-26 15:30:17 +00:00
"larghezza": Larghezza,
"altezza": Altezza,
2017-05-26 21:36:12 +00:00
2017-05-26 14:28:38 +00:00
}
2017-05-26 15:54:45 +00:00
http.HandleFunc("/tabella", handlerRoot("template/tabella.html"))
http.HandleFunc("/", handlerRoot("template/Interfaccia.html"))
2017-05-26 16:53:04 +00:00
fs := http.FileServer(http.Dir("static"))
http.Handle("/static/", http.StripPrefix("/static/", fs))
2017-05-26 15:54:45 +00:00
http.ListenAndServe(":3000", nil)
}
func handlerRoot(path string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
templ, err := template.ParseFiles(path)
if err != nil {
panic(err.Error())
}
templ.Execute(w, varmap)
}
2017-05-26 13:35:26 +00:00
}