minor locating feature fixes
All checks were successful
Flask Run Test / Flask-Run-Test (push) Successful in 11s

This commit is contained in:
2026-01-12 11:49:56 +09:00
parent db5a88972b
commit 39917b7351
2 changed files with 45 additions and 30 deletions

View File

@@ -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>