1
0
into-the-llm/interface/htmlthing.html

74 lines
2.4 KiB
HTML
Raw Normal View History

2024-10-06 21:53:14 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flask Screenshot & Click</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
#screenshot {
margin-top: 20px;
cursor: pointer;
}
.message {
margin-top: 20px;
color: green;
}
</style>
</head>
<body>
<h1>Flask Screenshot & Click App</h1>
<p><strong>Take a Screenshot:</strong></p>
<button onclick="takeScreenshot()">Take Screenshot</button>
<div id="screenshot-div">
<p><strong>Click on the Image to Trigger Click at X, Y:</strong></p>
<img id="screenshot" width='1280px' height='720px' style="display:none;" />
</div>
<div class="message" id="click-message"></div>
<script>
// Function to take a screenshot by calling the Flask /screenshot endpoint
function takeScreenshot() {
fetch('/screenshot')
.then(response => response.blob())
.then(imageBlob => {
const imageUrl = URL.createObjectURL(imageBlob);
const screenshotImage = document.getElementById('screenshot');
screenshotImage.src = imageUrl;
screenshotImage.style.display = 'block';
})
.catch(error => {
console.error('Error taking screenshot:', error);
});
}
// Function to simulate a click at the (x, y) coordinates of the image
const clickableImage = document.getElementById('screenshot');
clickableImage.addEventListener('click', function(event) {
const x = event.pageX - this.offsetLeft;
const y = event.pageY - this.offsetTop;
// Trigger the Flask /click/x/y endpoint using the x and y coordinates of the click
fetch(`/click/${x}/${y}`)
.then(response => response.text())
.then(message => {
document.getElementById('click-message').innerText = message;
})
.catch(error => {
console.error('Error triggering click:', error);
})
.then(() => {
takeScreenshot();
});
});
</script>
</body>
</html>