mydemo1 / templates /index3.html
CloudAnts's picture
my
d602994
raw
history blame
5.51 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Invoice Extraction</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
/* Your existing styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Poppins', sans-serif; background: linear-gradient(to right, #6a11cb, #2575fc); color: #333; display: flex; justify-content: center; align-items: center; height: 100vh; }
.container { width: 90%; max-width: 600px; background: #ffffff; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); border-radius: 12px; padding: 30px; }
.header { text-align: center; margin-bottom: 20px; }
.header h1 { font-size: 28px; font-weight: 700; color: #333; }
.header p { font-size: 14px; color: #777; }
.upload-section { margin-bottom: 20px; }
.upload-section label { display: block; font-size: 16px; font-weight: 500; margin-bottom: 10px; color: #555; }
.upload-section input[type="file"] { display: block; padding: 12px; font-size: 14px; border: 1px solid #ddd; border-radius: 8px; width: 100%; transition: all 0.3s ease; }
.upload-section input[type="file"]:focus { border-color: #2575fc; outline: none; }
.actions { text-align: center; margin-top: 10px; }
.actions button { background-color: #2575fc; color: white; padding: 12px 25px; border: none; border-radius: 8px; font-size: 16px; font-weight: 500; cursor: pointer; transition: background-color 0.3s ease; margin: 10px 5px; }
.actions button:hover { background-color: #1a5bb8; }
.output-section { margin-top: 20px; text-align: center; display: none; }
.please-wait { font-size: 18px; font-weight: 600; color: #ffcc00; display: none; text-align: center; }
/* Spinner styling */
.spinner {
border: 4px solid #f3f3f3; /* Light background */
border-top: 4px solid #2575fc; /* Blue color for the spinning part */
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 2s linear infinite;
margin: 10px auto;
}
/* Spinner animation */
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.output-section button { background-color: #34c759; color: white; padding: 10px 20px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background-color 0.3s ease; margin: 10px 5px; }
.output-section button:hover { background-color: #28a745; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Invoice Processing</h1>
<p>Upload your invoice and extract data with ease</p>
</div>
<div class="upload-section">
<label for="invoice-upload">Upload Invoice Image:</label>
<input type="file" id="invoice-upload" accept="image/*">
</div>
<div class="actions">
<button id="upload-btn">Upload & Process</button>
</div>
<!-- Please Wait Section with Spinner -->
<div class="please-wait" id="please-wait">
<div class="spinner"></div>
Please wait, processing the file...
</div>
<!-- Output Section (Buttons only) -->
<div class="output-section" id="output-section">
<a id="download-csv" href="" download><button>Download CSV</button></a>
<a id="download-image" href="" download><button>Download Annotated Image</button></a>
</div>
</div>
<script>
const uploadBtn = document.getElementById('upload-btn');
const invoiceInput = document.getElementById('invoice-upload');
const outputSection = document.getElementById('output-section');
const pleaseWaitSection = document.getElementById('please-wait');
const downloadCsvButton = document.getElementById('download-csv');
const downloadImageButton = document.getElementById('download-image');
uploadBtn.addEventListener('click', () => {
const file = invoiceInput.files[0];
if (!file) return alert('Please select a file.');
const formData = new FormData();
formData.append('invoice-upload', file);
// Show the "Please Wait" message and spinner
pleaseWaitSection.style.display = 'block';
outputSection.style.display = 'none';
// Send the file to the server for processing
fetch('/upload', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
pleaseWaitSection.style.display = 'none'; // Hide "Please Wait"
outputSection.style.display = 'block'; // Show download buttons
downloadCsvButton.href = `/download_csv/${data.csv_path.split('/').pop()}`;
downloadImageButton.href = `/download_image/${data.image_path.split('/').pop()}`;
})
.catch(error => {
pleaseWaitSection.style.display = 'none'; // Hide "Please Wait"
alert('Error processing the image: ' + error);
});
});
</script>
</body>
</html>