secajs/views/index.ejs
2025-02-08 01:14:01 +01:00

61 lines
No EOL
1.9 KiB
Text

<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello World</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Hello World! We're live</h1>
<p>Now this is some production grade stuff, baby!</p>
<p>Your session's UUID: <%= uuid %>
</p>
<p id="pubkey-p" style="display:none">And your pubkey is: <span id="pubkey-span"></span></p>
</body>
<script>
window.onload = function () {
setTimeout(function () {
console.log("This code runs 2 seconds after the window has loaded.");
const npub = window.nostr.getPublicKey();
let pubkeyP = document.querySelector("#pubkey-p");
let pubkeySpan = document.querySelector("#pubkey-span");
npub.then(async function (npub) {
console.log(npub);
pubkeyP.style.display = "block";
pubkeySpan.innerText = npub;
try {
const response = await fetch('/api/session-npubbed', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"npub": npub
})
});
if (response.ok) {
const data = await response.json();
console.log('SessionNpubbed record created successfully:', data);
} else {
const error = await response.json();
console.error('Failed to create sessionNpubbed record:', error);
}
} catch (error) {
console.error('An error occurred:', error);
}
}
)
}, 2000);
}
</script>
</html>