I'm trying to create a simple server in Go. I have it set up so that it will show me a page when I make a GET request to "/".
func main() {
http.HandleFunc("/", serveHomePage)
http.ListenAndServe(":8000", nil)
}
func serveHomePage(w http.ResponseWriter, r *http.Request) {
homePageTemplate, err := template.ParseFiles("index.html")
if err == nil {
homePageTemplate.Execute(w, nil)
} else {
panic("Something went wrong with the template!")
}
}
I have my index.html
in the same folder as my server.go
file.
My directory looks like this:
.
├── index.html
├── scripts
│ ├── jquery.min.js
│ └── main.js
├── server.go
└── styles
└── main.css
And my index.html
has:
<html>
<head>
<link rel="stylesheet" href="./styles/main.css">
</head>
<body>
<div class="container">
<form id="urlSubmitForm">
<input type="url">
<button type="submit">Submit URL!</button>
</form>
</div>
<script src="./scripts/jquery.min.js"></script>
<script src="./scripts/main.js"></script>
</body>
</html>
The error I am getting says,
Uncaught SyntaxError: Unexpected token <
on line 1 of my main.js
file and line 1 of the jquery.min.js
file.
If I click on the error, it points to the first line of my index.html
file.
For reference (though I think this isn't relevant), here is my main.js file.
$(document).on("ready", function() {
});