Skip to content

Commit

Permalink
try to make web page more snappy (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
wafer-bw authored Jun 23, 2024
1 parent 2a431fa commit 77676dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/wafer-bw/whatsmyip

go 1.21

toolchain go1.21.7
go 1.22.4

require (
github.com/golangci/golangci-lint v1.59.0
Expand Down
12 changes: 11 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<meta name="theme-color" content="#fff" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Golang API running as a Vercel Serverless Function which returns your public IP address">
<script src="./js/setIp.js" async></script>
</head>

<body>
Expand All @@ -28,6 +27,17 @@ <h2>Your public IP address is: <div id="ip"></div></h2>
</div>
</div>
</div>
<script>
fetch("/api", { headers: { 'accept': 'application/json' } })
.then(response => response.json())
.then(data => {
document.getElementById("ip").innerHTML = data["ip"]
}).catch(err => {
msg = "There was a problem getting your IP address"
document.getElementById("ip").innerHTML = msg
console.error(err)
})
</script>
</body>

</html>
9 changes: 0 additions & 9 deletions public/js/setIp.js

This file was deleted.

0 comments on commit 77676dc

Please sign in to comment.