mirror of
https://gitlab.durp.info/durfy/apps/durpweb.git
synced 2026-05-07 07:50:31 -05:00
32 lines
625 B
Go
32 lines
625 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"html/template"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
tmpl, err := template.ParseFiles("index.html")
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
}
|
|
|
|
data := struct {
|
|
Message string
|
|
}{
|
|
Message: "Hello World",
|
|
}
|
|
|
|
tmpl.Execute(w, data)
|
|
})
|
|
|
|
http.HandleFunc("/time", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Write([]byte("Current Time: " + time.Now().Format(time.RFC1123)))
|
|
})
|
|
|
|
fmt.Println("Started http server on port :8080")
|
|
http.ListenAndServe(":8080", nil)
|
|
}
|