feat: html static templates
This commit is contained in:
parent
9d0da00371
commit
e9fc659a5a
12 changed files with 91 additions and 100 deletions
12
src/views.go
12
src/views.go
|
@ -2,15 +2,15 @@ package main
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func index(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, filepath.Join("html", "index.html"))
|
||||
r.URL.Path = "/contact"
|
||||
html(w, r)
|
||||
}
|
||||
|
||||
func style(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "/html/style.css")
|
||||
http.ServeFile(w, r, "html/style.css")
|
||||
}
|
||||
|
||||
func static(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -18,5 +18,9 @@ func static(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func html(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, filepath.Join("html", r.URL.Path + ".html"))
|
||||
if t, found := TMPL[r.URL.Path]; found {
|
||||
w.Write(t)
|
||||
} else {
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue