|
|
|
|
@ -1,18 +1,22 @@
|
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"embed" |
|
|
|
|
"html/template" |
|
|
|
|
"log" |
|
|
|
|
"net/http" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
//go:embed static
|
|
|
|
|
var staticFiles embed.FS |
|
|
|
|
|
|
|
|
|
type Guestbook struct { |
|
|
|
|
Comments []string |
|
|
|
|
Count int |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func indexHandler(writer http.ResponseWriter, request *http.Request) { |
|
|
|
|
html, err := template.ParseFiles("html/index.html") |
|
|
|
|
html, err := template.ParseFS(staticFiles, "static/index.html") |
|
|
|
|
check(err) |
|
|
|
|
|
|
|
|
|
store := TxtStore("comments.txt") |
|
|
|
|
@ -37,7 +41,8 @@ func main() {
|
|
|
|
|
http.HandleFunc("/", indexHandler) |
|
|
|
|
http.HandleFunc("/new", newHandler) |
|
|
|
|
|
|
|
|
|
http.Handle("/html/", http.StripPrefix("/html/", http.FileServer(http.Dir("html")))) |
|
|
|
|
var staticFS = http.FS(staticFiles) |
|
|
|
|
http.Handle("/static/", http.FileServer(staticFS)) |
|
|
|
|
|
|
|
|
|
err := http.ListenAndServe("0.0.0.0:80", nil) |
|
|
|
|
log.Fatal(err) |
|
|
|
|
|