secajs/src/views/index.ejs

64 lines
2 KiB
Text
Raw Normal View History

2025-02-06 19:20:16 +01:00
<!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>
2025-02-06 22:59:24 +01:00
<p>Your session's UUID: <%= uuid %>
</p>
2025-02-08 01:14:01 +01:00
<p id="pubkey-p" style="display:none">And your pubkey is: <span id="pubkey-span"></span></p>
2025-02-09 18:47:04 +01:00
<hr>
<p>Here's a kitty, cause why not</p>
<img width="300px" src="kitty.jpeg" alt="">
2025-02-06 19:20:16 +01:00
</body>
2025-02-08 01:14:01 +01:00
<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>
2025-02-06 19:20:16 +01:00
</html>