-
Notifications
You must be signed in to change notification settings - Fork 0
/
idx2.html
31 lines (30 loc) · 870 Bytes
/
idx2.html
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
27
28
29
30
31
<html>
<head>
</head>
<body>
<img id="image" width="100%" src="">
<script type="text/javascript">
myImage = document.querySelector('img');
urlObj = null
function getImg() {
fetch('/image?stream=true&&user={{.User}}&pwd={{.Pwd}}&addr={{.Addr}}', {
headers: {
'X-Idx': '{{.Idx}}',
},
})
.then(function(response) {
if (!response.ok) {
throw new Error('HTTP error! status: ${response.status}');
}
return response.blob();
})
.then(function (blob) {
if (urlObj != null) URL.revokeObjectURL(urlObj)
urlObj = URL.createObjectURL(blob)
myImage.src = urlObj
})
}
window.setInterval(getImg, 100)
</script>
</body>
</html>