From 8ded814424bfdc29f8cf8c64e417d167941df421 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Wed, 19 Oct 2016 20:27:46 +0200 Subject: [PATCH] Initial survey --- home.go | 11 +++ home.html | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++++ main.go | 21 ++++++ thanks.html | 16 +++++ vote.go | 20 ++++++ 5 files changed, 267 insertions(+) create mode 100644 home.go create mode 100644 home.html create mode 100644 main.go create mode 100644 thanks.html create mode 100644 vote.go diff --git a/home.go b/home.go new file mode 100644 index 0000000..7656056 --- /dev/null +++ b/home.go @@ -0,0 +1,11 @@ +package main + +import ( + "log" + "net/http" +) + +func Home(w http.ResponseWriter, r *http.Request) { + log.Printf("Serve home page to %s: %s [%s]\n", r.Header.Get("X-Forwarded-For"), r.URL.Path, r.UserAgent()) + http.ServeFile(w, r, "home.html") +} diff --git a/home.html b/home.html new file mode 100644 index 0000000..906ff95 --- /dev/null +++ b/home.html @@ -0,0 +1,199 @@ + + + + Sondage VIRLI + + + + +

Virtualisation légère — SRS 2017

+ +

+ Aidez-moi à améliorer ce cours en donnant votre avis. +

+ +
+ +
+

Quel est le cours/TP que vous avez préféré ?

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+

Quel(s) cours mériterait, selon vous, d'être complété/approfondi ?

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+

Diriez-vous que ce cours a :

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+

Les TP, principalement :

+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+ +
+

Quelle raison vous a principalement poussée à ne pas assister au cours ?

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+

Laissez votre avis et n'hésitez pas à compléter les réponses que vous avez donné ci-dessus

+ +
+ +
+ + diff --git a/main.go b/main.go new file mode 100644 index 0000000..b120530 --- /dev/null +++ b/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "flag" + "fmt" + "log" + "net/http" +) + +func main() { + var bind = flag.String("bind", "0.0.0.0:8081", "Bind port/socket") + flag.Parse() + + log.Println("Registering handlers...") + http.HandleFunc("/", Home) + http.HandleFunc("/vote", Vote) + log.Println(fmt.Sprintf("Ready, listening on %s", *bind)) + if err := http.ListenAndServe(*bind, nil); err != nil { + log.Fatal("Unable to listen and serve: ", err) + } +} diff --git a/thanks.html b/thanks.html new file mode 100644 index 0000000..661e9d1 --- /dev/null +++ b/thanks.html @@ -0,0 +1,16 @@ + + + + Sondage VIRLI + + + + +

Virtualisation légère — SRS 2017

+ + + + + diff --git a/vote.go b/vote.go new file mode 100644 index 0000000..1cdfc8a --- /dev/null +++ b/vote.go @@ -0,0 +1,20 @@ +package main + +import ( + "log" + "net/http" +) + +func Vote(w http.ResponseWriter, r *http.Request) { + if r.Method == "POST" { + r.ParseForm() + log.Printf("Handling new vote from %s: %s [%s]\n", r.Header.Get("X-Forwarded-For"), r.URL.Path, r.UserAgent()) + for k, v := range r.PostForm { + log.Println(k + ":", v) + } + + http.ServeFile(w, r, "thanks.html") + } else { + http.NotFound(w, r) + } +}