minor locating feature fixes
All checks were successful
Flask Run Test / Flask-Run-Test (push) Successful in 11s
All checks were successful
Flask Run Test / Flask-Run-Test (push) Successful in 11s
This commit is contained in:
@@ -226,21 +226,24 @@
|
||||
</script>
|
||||
<script>
|
||||
async function loadLocation() {
|
||||
try {
|
||||
const response = await fetch('/get-location');
|
||||
const data = await response.json();
|
||||
|
||||
if (data.status === 'success') {
|
||||
document.getElementById('location-display').innerHTML =
|
||||
`${data.city}, ${data.country} <small>(${data.isp})</small>`;
|
||||
document.getElementById('location-display').classList.remove('loading');
|
||||
} else {
|
||||
throw new Error();
|
||||
}
|
||||
} catch (err) {
|
||||
document.getElementById('location-display').innerText = "Unknown Location";
|
||||
}
|
||||
try {
|
||||
// This calls the API from the USER'S browser.
|
||||
// The API will see the User's Real IP directly.
|
||||
const response = await fetch('https://ipapi.co/json/');
|
||||
const data = await response.json();
|
||||
|
||||
if (data.city && data.country_name) {
|
||||
document.getElementById('location-display').innerText =
|
||||
`${data.city}, ${data.country_name}`;
|
||||
document.getElementById('location-display').classList.remove('loading');
|
||||
} else {
|
||||
throw new Error("Missing data");
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Location Error:", err);
|
||||
document.getElementById('location-display').innerText = "Unknown Location";
|
||||
}
|
||||
}
|
||||
loadLocation();
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user