DmitrMakeev commited on
Commit
12c46c8
·
verified ·
1 Parent(s): 076b19e

Update se_mes_im2.html

Browse files
Files changed (1) hide show
  1. se_mes_im2.html +43 -53
se_mes_im2.html CHANGED
@@ -1,54 +1,44 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Upload Image</title>
7
- </head>
8
- <body>
9
- <h1>Upload Image</h1>
10
- <form id="uploadForm">
11
- <input type="file" id="fileInput" accept="image/*">
12
- <button type="submit">Upload</button>
13
- </form>
14
- <div id="message"></div>
15
- <div id="newFilename"></div>
16
-
17
- <script>
18
- document.getElementById('uploadForm').addEventListener('submit', function(event) {
19
- event.preventDefault();
20
- const fileInput = document.getElementById('fileInput');
21
- const file = fileInput.files[0];
22
- if (!file) {
23
- document.getElementById('message').innerText = 'No file selected';
24
- return;
25
- }
26
- const formData = new FormData();
27
- formData.append('file', file);
28
- fetch('https://api.green-api.com/waInstance1101952913/uploadFile/fb4986a9d9cb40ef9be6c7b08cb9c98b7a3b1dc8c6834b0b92', {
29
- method: 'POST',
30
- body: formData
31
- })
32
- .then(response => {
33
- if (!response.ok) {
34
- return response.text().then(text => { throw new Error(text) });
35
- }
36
- return response.json();
37
- })
38
- .then(data => {
39
- if (data.urlFile) {
40
- const newFilename = data.urlFile.split('/').pop();
41
- document.getElementById('message').innerText = 'File uploaded successfully';
42
- document.getElementById('newFilename').innerText = `New filename: ${newFilename}`;
43
- } else {
44
- document.getElementById('message').innerText = 'Failed to upload file';
45
- }
46
- })
47
- .catch(error => {
48
- console.error('Error:', error);
49
- document.getElementById('message').innerText = 'Error: ' + error.message;
50
  });
51
- });
52
- </script>
53
- </body>
54
- </html>
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Camera Image</title>
7
+ </head>
8
+ <body>
9
+ <h1>Upload Image</h1>
10
+ <form id="uploadForm" enctype="multipart/form-data" method="post" action="/upload">
11
+ <input type="file" name="photo">
12
+ <button type="submit">Upload</button>
13
+ </form>
14
+ <div id="message"></div>
15
+ <h1>Latest Image</h1>
16
+ <img id="cameraImage" src="/image" alt="Image" style="width:100%;">
17
+ <script>
18
+ document.getElementById('uploadForm').addEventListener('submit', function(event) {
19
+ event.preventDefault();
20
+ var formData = new FormData(this);
21
+ fetch('/upload', {
22
+ method: 'POST',
23
+ body: formData
24
+ })
25
+ .then(response => {
26
+ if (response.ok) {
27
+ return response.text();
28
+ }
29
+ throw new Error('Network response was not ok.');
30
+ })
31
+ .then(data => {
32
+ document.getElementById('message').innerText = data;
33
+ })
34
+ .catch(error => {
35
+ document.getElementById('message').innerText = 'Error: ' + error.message;
36
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  });
38
+ setInterval(function(){
39
+ var image = document.getElementById("cameraImage");
40
+ image.src = "/image?" + new Date().getTime();
41
+ }, 10000); // обновление каждые 10 секунд
42
+ </script>
43
+ </body>
44
+ </html>