Update static/index.html
Browse files- static/index.html +17 -15
static/index.html
CHANGED
|
@@ -3,20 +3,22 @@
|
|
| 3 |
<head>
|
| 4 |
<title>Face2Vintage</title>
|
| 5 |
<script>
|
| 6 |
-
document.
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
});
|
| 21 |
</script>
|
| 22 |
</head>
|
|
@@ -24,7 +26,7 @@
|
|
| 24 |
<h1>Upload Image</h1>
|
| 25 |
<form id="uploadForm" enctype="multipart/form-data">
|
| 26 |
<input type="file" id="imageInput" name="file">
|
| 27 |
-
<input type="submit" value="Upload Image"
|
| 28 |
</form>
|
| 29 |
|
| 30 |
<div id="resultContainer"></div>
|
|
|
|
| 3 |
<head>
|
| 4 |
<title>Face2Vintage</title>
|
| 5 |
<script>
|
| 6 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 7 |
+
document.getElementById('uploadForm').addEventListener('submit', async function(event) {
|
| 8 |
+
event.preventDefault();
|
| 9 |
+
const formData = new FormData(this);
|
| 10 |
+
try {
|
| 11 |
+
const response = await fetch('/process_image/', {
|
| 12 |
+
method: 'POST',
|
| 13 |
+
body: formData
|
| 14 |
+
});
|
| 15 |
+
const result = await response.blob();
|
| 16 |
+
const imageURL = URL.createObjectURL(result);
|
| 17 |
+
document.getElementById('resultContainer').innerHTML = `<img src="${imageURL}" alt="Result Image">`;
|
| 18 |
+
} catch (error) {
|
| 19 |
+
console.error('Error:', error);
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
});
|
| 23 |
</script>
|
| 24 |
</head>
|
|
|
|
| 26 |
<h1>Upload Image</h1>
|
| 27 |
<form id="uploadForm" enctype="multipart/form-data">
|
| 28 |
<input type="file" id="imageInput" name="file">
|
| 29 |
+
<input type="submit" value="Upload Image">
|
| 30 |
</form>
|
| 31 |
|
| 32 |
<div id="resultContainer"></div>
|