Ashrafb commited on
Commit
9b89541
·
verified ·
1 Parent(s): 0fe2699

Create static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +43 -0
static/index.html ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Image Background Removal</title>
7
+ </head>
8
+ <body>
9
+ <h1>Image Background Removal</h1>
10
+ <input type="file" id="fileInput" accept="image/*">
11
+ <button onclick="processImage()">Process Image</button>
12
+ <div id="output"></div>
13
+
14
+ <script>
15
+ async function processImage() {
16
+ const fileInput = document.getElementById('fileInput');
17
+ const file = fileInput.files[0];
18
+
19
+ const formData = new FormData();
20
+ formData.append('file', file);
21
+
22
+ try {
23
+ const response = await fetch('/process-image/', {
24
+ method: 'POST',
25
+ body: formData
26
+ });
27
+
28
+ if (!response.ok) {
29
+ throw new Error('Failed to process image');
30
+ }
31
+
32
+ const blob = await response.blob();
33
+ const imageUrl = URL.createObjectURL(blob);
34
+
35
+ const outputDiv = document.getElementById('output');
36
+ outputDiv.innerHTML = `<img src="${imageUrl}" alt="Processed Image">`;
37
+ } catch (error) {
38
+ console.error('Error:', error.message);
39
+ }
40
+ }
41
+ </script>
42
+ </body>
43
+ </html>