Skip to content

Commit

Permalink
Update website.go
Browse files Browse the repository at this point in the history
  • Loading branch information
adam0306 authored Jul 8, 2024
1 parent ae400ea commit 0f53e9a
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions website/go/website.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
// forms.go
package main

import "fmt"
import (
"html/template"
"net/http"
)

func main() {
fmt.Println("hello world")
type ContactDetails struct {
Email string
Subject string
Message string
}

func main() {
tmpl := template.Must(template.ParseFiles("forms.html"))

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
tmpl.Execute(w, nil)
return
}

details := ContactDetails{
Email: r.FormValue("email"),
Subject: r.FormValue("subject"),
Message: r.FormValue("message"),
}

// do something with details
_ = details

tmpl.Execute(w, struct{ Success bool }{true})
})

http.ListenAndServe(":8080", nil)
}

0 comments on commit 0f53e9a

Please sign in to comment.