Update AB/index.html
Browse files- AB/index.html +28 -4
AB/index.html
CHANGED
@@ -3,11 +3,11 @@
|
|
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 action="/upload/" method="post" enctype="multipart/form-data">
|
11 |
<label for="file">Select Image:</label><br>
|
12 |
<input type="file" id="file" name="file" accept="image/*" required><br><br>
|
13 |
|
@@ -23,7 +23,31 @@
|
|
23 |
<label for="right">Right:</label><br>
|
24 |
<input type="number" id="right" name="right" value="200" required><br><br>
|
25 |
|
26 |
-
<button type="submit">Upload and Process Image</button>
|
27 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
</body>
|
29 |
</html>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Upload and Process Image</title>
|
7 |
</head>
|
8 |
<body>
|
9 |
+
<h1>Upload and Process Image</h1>
|
10 |
+
<form id="uploadForm" action="/upload/" method="post" enctype="multipart/form-data">
|
11 |
<label for="file">Select Image:</label><br>
|
12 |
<input type="file" id="file" name="file" accept="image/*" required><br><br>
|
13 |
|
|
|
23 |
<label for="right">Right:</label><br>
|
24 |
<input type="number" id="right" name="right" value="200" required><br><br>
|
25 |
|
26 |
+
<button type="submit" onclick="uploadAndProcessImage()">Upload and Process Image</button>
|
27 |
</form>
|
28 |
+
|
29 |
+
<div id="processedImage"></div>
|
30 |
+
|
31 |
+
<script>
|
32 |
+
async function uploadAndProcessImage() {
|
33 |
+
event.preventDefault();
|
34 |
+
|
35 |
+
const form = document.getElementById('uploadForm');
|
36 |
+
const formData = new FormData(form);
|
37 |
+
|
38 |
+
const response = await fetch('/upload/', {
|
39 |
+
method: 'POST',
|
40 |
+
body: formData
|
41 |
+
});
|
42 |
+
|
43 |
+
if (response.ok) {
|
44 |
+
const processedImage = await response.blob();
|
45 |
+
const imageUrl = URL.createObjectURL(processedImage);
|
46 |
+
document.getElementById('processedImage').innerHTML = `<img src="${imageUrl}" alt="Processed Image">`;
|
47 |
+
} else {
|
48 |
+
alert('Error processing image');
|
49 |
+
}
|
50 |
+
}
|
51 |
+
</script>
|
52 |
</body>
|
53 |
</html>
|