Ashrafb commited on
Commit
1140f00
·
verified ·
1 Parent(s): 0fb1caa

Rename index.html to static/index.html

Browse files
Files changed (1) hide show
  1. index.html → static/index.html +14 -18
index.html → static/index.html RENAMED
@@ -3,34 +3,30 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Image to Sketch</title>
7
  </head>
8
  <body>
9
- <h1>Image to Sketch</h1>
10
- <form action="/upload/" method="post" enctype="multipart/form-data">
11
- <input type="file" name="file">
12
- <button type="submit">Upload</button>
13
- </form>
14
- <div id="result"></div>
15
-
16
  <script>
17
- async function uploadFile() {
 
 
 
 
18
  const formData = new FormData();
19
- const fileInput = document.querySelector('input[type="file"]');
20
- formData.append('file', fileInput.files[0]);
21
 
22
  const response = await fetch('/upload/', {
23
  method: 'POST',
24
  body: formData
25
  });
26
 
27
- const data = await response.json();
28
- document.getElementById('result').innerHTML = `<img src="data:image/png;base64,${data.sketch_image}" />`;
29
- }
30
-
31
- document.querySelector('form').addEventListener('submit', function(event) {
32
- event.preventDefault();
33
- uploadFile();
34
  });
35
  </script>
36
  </body>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Sketch Image Result</title>
7
  </head>
8
  <body>
9
+ <h1>Sketch Image Result</h1>
10
+ <input type="file" id="imageUpload" accept="image/*">
11
+ <img id="resultImage" src="" alt="Result Image">
12
+
 
 
 
13
  <script>
14
+ const imageUpload = document.getElementById('imageUpload');
15
+ const resultImage = document.getElementById('resultImage');
16
+
17
+ imageUpload.addEventListener('change', async function(event) {
18
+ const file = event.target.files[0];
19
  const formData = new FormData();
20
+ formData.append('file', file);
 
21
 
22
  const response = await fetch('/upload/', {
23
  method: 'POST',
24
  body: formData
25
  });
26
 
27
+ const responseData = await response.json();
28
+ const resultImageUrl = responseData.sketch_image;
29
+ resultImage.src = resultImageUrl;
 
 
 
 
30
  });
31
  </script>
32
  </body>