Brcb2 / static /index1.html
Ashrafb's picture
Rename static/index.html to static/index1.html
ece04d6 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Background Removal</title>
</head>
<body>
<h1>Image Background Removal</h1>
<input type="file" id="fileInput" accept="image/*">
<button onclick="processImage()">Process Image</button>
<div id="output"></div>
<script>
async function processImage() {
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
const formData = new FormData();
formData.append('file', file);
try {
const response = await fetch('/process-image/', {
method: 'POST',
body: formData
});
if (!response.ok) {
throw new Error('Failed to process image');
}
const blob = await response.blob();
const imageUrl = URL.createObjectURL(blob);
const outputDiv = document.getElementById('output');
outputDiv.innerHTML = `<img src="${imageUrl}" alt="Processed Image">`;
} catch (error) {
console.error('Error:', error.message);
}
}
</script>
</body>
</html>