Golang HTML/template return 404 file not found

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Golang HTML/template return 404 file not found



I'm trying to render home.html on port 8080.



server.go


package main
import (
"html/template"
"net/http"
)

var homeT = template.Must(template.ParseFiles("exhibit-b/home.html"))

func home(w http.ResponseWriter, r *http.Request) {
homeT.Execute(w, nil)
}

func main() {
http.HandleFunc("/home", home)
http.ListenAndServe(":8080", nil)
}



home.html


<!DOCTYPE html>
<html>
<title>Learning Go</title>
<body>
<h1>Yes I understand!</h1>
<h2>... and I would like to do something more interesting</h2>
</body>
</html>



But when I run the above code go run server.go the server starts but when I go to localhost:8080 I just see 404 error


go run server.go









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

lm SfvOWIJmz2T PiQhWy kPmiK21RZsKFwKRo1nxA Z,3LRN16bOwaMDzB2 8kvZPA0dDqdr
wvYqSHIG0eOhsFoAnDZ5qmGWhWXH KRlQoNoH3M1RnlN7jwTeEJQ lwXSzhlgaGBBZDLy

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Regex - How to capture all iterations of a repeating pattern?