Update static/index.html
Browse files- static/index.html +29 -3
static/index.html
CHANGED
|
@@ -2,12 +2,38 @@
|
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
<title>Face2Vintage</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<h1>Upload Image</h1>
|
| 8 |
-
<form
|
| 9 |
-
<input type="file" name="file">
|
| 10 |
-
<input type="submit" value="Upload Image">
|
| 11 |
</form>
|
|
|
|
|
|
|
|
|
|
| 12 |
</body>
|
| 13 |
</html>
|
|
|
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
<title>Face2Vintage</title>
|
| 5 |
+
<script>
|
| 6 |
+
async function uploadImage(event) {
|
| 7 |
+
event.preventDefault();
|
| 8 |
+
|
| 9 |
+
const formData = new FormData();
|
| 10 |
+
formData.append('file', document.getElementById('imageInput').files[0]);
|
| 11 |
+
|
| 12 |
+
const response = await fetch('/process_image/', {
|
| 13 |
+
method: 'POST',
|
| 14 |
+
body: formData
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
if (response.ok) {
|
| 18 |
+
const resultImage = await response.blob();
|
| 19 |
+
const imageUrl = URL.createObjectURL(resultImage);
|
| 20 |
+
|
| 21 |
+
// Display the result image
|
| 22 |
+
document.getElementById('resultImage').src = imageUrl;
|
| 23 |
+
} else {
|
| 24 |
+
console.error('Failed to process image');
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
</script>
|
| 28 |
</head>
|
| 29 |
<body>
|
| 30 |
<h1>Upload Image</h1>
|
| 31 |
+
<form id="uploadForm" enctype="multipart/form-data">
|
| 32 |
+
<input type="file" id="imageInput" name="file">
|
| 33 |
+
<input type="submit" value="Upload Image" onclick="uploadImage(event)">
|
| 34 |
</form>
|
| 35 |
+
|
| 36 |
+
<h2>Result Image</h2>
|
| 37 |
+
<img id="resultImage" src="" alt="Result Image">
|
| 38 |
</body>
|
| 39 |
</html>
|