Spaces:
Sleeping
Sleeping
Update se_mes_im2.html
Browse files- se_mes_im2.html +27 -26
se_mes_im2.html
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
<!DOCTYPE html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
|
@@ -16,32 +15,34 @@
|
|
| 16 |
<h1>Latest Image</h1>
|
| 17 |
<img id="cameraImage" src="/image" alt="Image" style="width:100%;">
|
| 18 |
<script>
|
| 19 |
-
document.
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
});
|
| 40 |
-
})
|
| 41 |
-
.catch(error => {
|
| 42 |
-
document.getElementById('message').innerText = 'Error: ' + error.message;
|
| 43 |
});
|
| 44 |
});
|
| 45 |
</script>
|
| 46 |
</body>
|
| 47 |
-
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
|
|
|
| 15 |
<h1>Latest Image</h1>
|
| 16 |
<img id="cameraImage" src="/image" alt="Image" style="width:100%;">
|
| 17 |
<script>
|
| 18 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 19 |
+
fetch('/own_url')
|
| 20 |
+
.then(response => response.text())
|
| 21 |
+
.then(ownUrl => {
|
| 22 |
+
document.getElementById('uploadForm').addEventListener('submit', function(event) {
|
| 23 |
+
event.preventDefault();
|
| 24 |
+
var formData = new FormData(this);
|
| 25 |
+
fetch('/upload', {
|
| 26 |
+
method: 'POST',
|
| 27 |
+
body: formData
|
| 28 |
+
})
|
| 29 |
+
.then(response => {
|
| 30 |
+
if (response.ok) {
|
| 31 |
+
return response.text();
|
| 32 |
+
}
|
| 33 |
+
throw new Error('Network response was not ok.');
|
| 34 |
+
})
|
| 35 |
+
.then(data => {
|
| 36 |
+
document.getElementById('message').innerText = data;
|
| 37 |
+
var image = document.getElementById("cameraImage");
|
| 38 |
+
image.src = ownUrl + "/image?" + new Date().getTime();
|
| 39 |
+
})
|
| 40 |
+
.catch(error => {
|
| 41 |
+
document.getElementById('message').innerText = 'Error: ' + error.message;
|
| 42 |
+
});
|
| 43 |
});
|
|
|
|
|
|
|
|
|
|
| 44 |
});
|
| 45 |
});
|
| 46 |
</script>
|
| 47 |
</body>
|
| 48 |
+
</html>
|