feat: responding with a basic template
This commit is contained in:
parent
f30d9dad94
commit
e834ff06ab
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
@ -14,10 +15,16 @@ var publicContent embed.FS
|
||||
func main() {
|
||||
// visible on http://localhost:8080/static/public/some-text.txt
|
||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(publicContent))))
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
http.HandleFunc("/hello", func(w http.ResponseWriter, req *http.Request) {
|
||||
io.WriteString(w, "This is temporary here, hello")
|
||||
})
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
||||
tmpl := template.Must(template.ParseFiles("templates/summary-component.gohtml"))
|
||||
tmpl.Execute(w, nil)
|
||||
})
|
||||
|
||||
log.Print("starting server on default :8080")
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>HTML5 Boilerplate</title>
|
||||
<link rel="stylesheet" href="/static/public/out.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Page Title</h1>
|
||||
<script src="scripts.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user