Ashrafb commited on
Commit
38f9a32
1 Parent(s): 6e55d6b

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +21 -1
static/index.html CHANGED
@@ -9,7 +9,7 @@
9
  </head>
10
  <body>
11
  <h1>Image Enhancement</h1>
12
- <form action="/upload/" method="post" enctype="multipart/form-data">
13
  <label for="image">Upload Image:</label>
14
  <input type="file" id="image" name="file" accept="image/*" required><br><br>
15
 
@@ -30,5 +30,25 @@
30
 
31
  <button type="submit">Enhance Image</button>
32
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  </body>
34
  </html>
 
9
  </head>
10
  <body>
11
  <h1>Image Enhancement</h1>
12
+ <form id="uploadForm" enctype="multipart/form-data">
13
  <label for="image">Upload Image:</label>
14
  <input type="file" id="image" name="file" accept="image/*" required><br><br>
15
 
 
30
 
31
  <button type="submit">Enhance Image</button>
32
  </form>
33
+
34
+ <div id="resultContainer"></div>
35
+
36
+ <script>
37
+ document.getElementById('uploadForm').addEventListener('submit', async function(event) {
38
+ event.preventDefault();
39
+ const formData = new FormData(this);
40
+ try {
41
+ const response = await fetch('/upload/', {
42
+ method: 'POST',
43
+ body: formData
44
+ });
45
+ const result = await response.blob();
46
+ const imageURL = URL.createObjectURL(result);
47
+ document.getElementById('resultContainer').innerHTML = `<img src="${imageURL}" alt="Enhanced Image">`;
48
+ } catch (error) {
49
+ console.error('Error:', error);
50
+ }
51
+ });
52
+ </script>
53
  </body>
54
  </html>