|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>CSV Upload</title> |
|
<style> |
|
.loader { |
|
border: 16px solid #f3f3f3; |
|
border-radius: 50%; |
|
border-top: 16px solid #4CAF50; |
|
width: 120px; |
|
height: 120px; |
|
-webkit-animation: spin 2s linear infinite; |
|
animation: spin 2s linear infinite; |
|
display: none; |
|
position: fixed; |
|
top: 50%; |
|
left: 50%; |
|
transform: translate(-50%, -50%); |
|
} |
|
|
|
|
|
@-webkit-keyframes spin { |
|
0% { -webkit-transform: rotate(0deg); } |
|
100% { -webkit-transform: rotate(360deg); } |
|
} |
|
|
|
@keyframes spin { |
|
0% { transform: rotate(0deg); } |
|
100% { transform: rotate(360deg); } |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<h1>Upload CSV File</h1> |
|
<form id="uploadForm" enctype="multipart/form-data" method="post"> |
|
<input type="file" name="file" accept=".csv"> |
|
<label> |
|
<input type="checkbox" name="verify_phone" value="1"> Verify Phone |
|
</label> |
|
<label> |
|
<input type="checkbox" name="add_curator" value="1"> Add Curator |
|
</label> |
|
<input type="submit" value="Upload"> |
|
</form> |
|
<div id="result"></div> |
|
<div class="loader"></div> |
|
|
|
<script> |
|
document.getElementById('uploadForm').addEventListener('submit', function(event) { |
|
event.preventDefault(); |
|
const form = new FormData(this); |
|
const loader = document.querySelector('.loader'); |
|
loader.style.display = 'block'; |
|
|
|
fetch('/upload_csv', { |
|
method: 'POST', |
|
body: form |
|
}) |
|
.then(response => response.json()) |
|
.then(data => { |
|
document.getElementById('result').innerText = JSON.stringify(data, null, 2); |
|
loader.style.display = 'none'; |
|
}) |
|
.catch(error => { |
|
console.error('Error:', error); |
|
loader.style.display = 'none'; |
|
}); |
|
}); |
|
</script> |
|
</body> |
|
</html> |