mirror of
https://gitlab.durp.info/durfy/apps/durpweb.git
synced 2026-05-07 07:50:31 -05:00
initial commit
This commit is contained in:
parent
24afc01911
commit
035a813154
7 changed files with 80 additions and 0 deletions
32
main.go
Normal file
32
main.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue