Golang HTML/template return 404 file not found

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.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

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

C++ virtual function: Base class function is called instead of derived