blob: fe998dfa8a9717280505449d96277a520f5758f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
Wish the web server handles route {/camera} with handler {
set camera [dict getdef $QUERY camera /any/]
html {
<html>
<body style="margin: 0 0">
<canvas id="cameraCanvas" style="max-width: 100%"></canvas>
<script>
const canvas = cameraCanvas;
const ctx = canvas.getContext('2d');
function advanceCamera() {
const img = new Image();
img.onload = () => {
canvas.width = img.naturalWidth;
canvas.height = img.naturalHeight;
ctx.drawImage(img, 0, 0);
setTimeout(advanceCamera, 0);
};
img.onerror = () => setTimeout(advanceCamera, 500);
img.src = '/camera-frame?uniq=' + Math.random();
}
advanceCamera();
</script>
</body>
</html>
}
}
|