From 744d7e0860ae17effaf4d02ae63b3a275f25d1c8 Mon Sep 17 00:00:00 2001 From: aziis98 Date: Wed, 4 Mar 2020 01:24:55 +0100 Subject: [PATCH] minimal go web server --- go.mod | 3 +++ main.go | 21 +++++++++++++++++++++ views/home.html | 13 +++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 go.mod create mode 100644 main.go create mode 100644 views/home.html diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1674a62 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module phc.dm.unipi.it/aziis98/nuovo-sito-poisson + +go 1.13 diff --git a/main.go b/main.go new file mode 100644 index 0000000..0300322 --- /dev/null +++ b/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "log" + "net/http" +) + +func serveHome(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "./views/home.html") +} + +func main() { + + http.HandleFunc("/", serveHome) + + log.Println("Listening on :8000...") + err := http.ListenAndServe(":8000", nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/views/home.html b/views/home.html new file mode 100644 index 0000000..241dd4c --- /dev/null +++ b/views/home.html @@ -0,0 +1,13 @@ + + + + + + PHC + + +

PHC Poisson

+ + Lorem, ipsum dolor sit amet consectetur adipisicing elit. Fuga reprehenderit similique pariatur asperiores? Adipisci commodi tempore perspiciatis culpa architecto, accusantium reprehenderit, nisi explicabo minus minima maiores ab consectetur totam quos. + + \ No newline at end of file