Stock_Detection / index.html
osamaifti's picture
Update index.html
bf24c1f verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload Image</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.image-container {
margin-top: 20px;
}
.image-container img {
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<h1>Upload an Image for Object Detection</h1>
<form id="uploadForm" enctype="multipart/form-data">
<input type="file" name="file" accept="image/*" required>
<button type="submit">Upload and Detect</button>
</form>
<div class="image-container" id="imageContainer"></div>
<script>
document.getElementById('uploadForm').addEventListener('submit', async function(event) {
event.preventDefault();
const formData = new FormData(this);
const response = await fetch('/', {
method: 'POST',
body: formData
});
const result = await response.json();
const imageUrl = result.image_url;
const imageContainer = document.getElementById('imageContainer');
imageContainer.innerHTML = `<h2>Detected Image:</h2><img src="${imageUrl}" alt="Detected Image">`;
});
</script>
</body>
</html>