From def227083a9f25fc207fdff24f1019825e6d8a94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Josu=C3=A9=20Rodr=C3=ADguez?= Date: Wed, 2 Aug 2023 04:38:54 +0000 Subject: [PATCH] changing the server port to flag --- templates/views/index.html | 2 +- vscpweb.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/views/index.html b/templates/views/index.html index d4a48b4..ee8248a 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -8,7 +8,7 @@ {{ . }} -

+

Hello world! {{ . }}

diff --git a/vscpweb.go b/vscpweb.go index a304d5a..24be893 100644 --- a/vscpweb.go +++ b/vscpweb.go @@ -34,9 +34,9 @@ func main() { port := flag.Int("port", 8001, "Port in which the server will be started") flag.Parse() setPort := strconv.Itoa(*port) - setPort = ":"+setPort + setPort = ":" + setPort - http.ListenAndServe(setPort , s.Router) + http.ListenAndServe(setPort, s.Router) } type server struct { @@ -142,8 +142,8 @@ func (s *server) MountHandlers() { // GenericHandler404 is the universal 404 response of this front end func GenericHandler404(w http.ResponseWriter, r *http.Request) { - -w.WriteHeader(404) + + w.WriteHeader(404) messages := []string{"route does not exist", "page not found", "resource not found"} randomIndex := rand.Intn(len(messages)) w.Write([]byte(messages[randomIndex])) @@ -163,9 +163,9 @@ func ExampleHandler(w http.ResponseWriter, r *http.Request) { func indexHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) - passarg := "some passing argument" + passarg := "some passing argument done" indexTemplate := template.Must(template.ParseFiles("templates/views/index.html")) - //check for go partial templates so you can extract blocks you want to use + //check for go partial templates so you can extract blocks you want to use indexTemplate.Execute(w, passarg) } -- 2.25.1