Files
fingerprint-api/fingerp/static/index.html
2026-03-24 18:28:37 -04:00

62 lines
2.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fingerprint Collector</title>
</head>
<body>
<h1>Fingerprint Collector</h1>
<p id="status">Collecting fingerprint...</p>
<script>
function getCanvasFingerprint() {
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
if (!ctx) return "";
ctx.textBaseline = "top";
ctx.font = "16px Arial";
ctx.fillText("fingerprint", 10, 10);
return canvas.toDataURL();
}
async function submitFingerprint() {
const fingerprint = getCanvasFingerprint();
try {
const response = await fetch("/fingerprint", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ fingerprint: fingerprint }),
});
const result = await response.json();
const hash = result.fingerprint_hash;
const checkResponse = await fetch("/fingerprint/" + hash);
const checkResult = await checkResponse.json();
const shortHash = hash.substring(0, 8);
if (checkResult.count > 1) {
document.getElementById("status").textContent =
"Hello, " + shortHash + ". We've seen you before!";
} else {
document.getElementById("status").textContent =
"Hello, " + shortHash + ". I see you're new here";
}
} catch (error) {
document.getElementById("status").textContent =
"Error: " + error.message;
}
}
submitFingerprint();
</script>
</body>
</html>