Update upl_csv.html
Browse files- upl_csv.html +33 -0
upl_csv.html
CHANGED
|
@@ -4,6 +4,33 @@
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>CSV Upload</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
</head>
|
| 8 |
<body>
|
| 9 |
<h1>Upload CSV File</h1>
|
|
@@ -18,11 +45,15 @@
|
|
| 18 |
<input type="submit" value="Upload">
|
| 19 |
</form>
|
| 20 |
<div id="result"></div>
|
|
|
|
| 21 |
|
| 22 |
<script>
|
| 23 |
document.getElementById('uploadForm').addEventListener('submit', function(event) {
|
| 24 |
event.preventDefault();
|
| 25 |
const form = new FormData(this);
|
|
|
|
|
|
|
|
|
|
| 26 |
fetch('/upload_csv', {
|
| 27 |
method: 'POST',
|
| 28 |
body: form
|
|
@@ -30,9 +61,11 @@
|
|
| 30 |
.then(response => response.json())
|
| 31 |
.then(data => {
|
| 32 |
document.getElementById('result').innerText = JSON.stringify(data, null, 2);
|
|
|
|
| 33 |
})
|
| 34 |
.catch(error => {
|
| 35 |
console.error('Error:', error);
|
|
|
|
| 36 |
});
|
| 37 |
});
|
| 38 |
</script>
|
|
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>CSV Upload</title>
|
| 7 |
+
<style>
|
| 8 |
+
.loader {
|
| 9 |
+
border: 16px solid #f3f3f3;
|
| 10 |
+
border-radius: 50%;
|
| 11 |
+
border-top: 16px solid #4CAF50; /* Зелёный цвет */
|
| 12 |
+
width: 120px;
|
| 13 |
+
height: 120px;
|
| 14 |
+
-webkit-animation: spin 2s linear infinite; /* Safari */
|
| 15 |
+
animation: spin 2s linear infinite;
|
| 16 |
+
display: none; /* Изначально скрыт */
|
| 17 |
+
position: fixed; /* Фиксированное положение */
|
| 18 |
+
top: 50%; /* По центру по вертикали */
|
| 19 |
+
left: 50%; /* По центру по горизонтали */
|
| 20 |
+
transform: translate(-50%, -50%); /* Центрирование */
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/* Safari */
|
| 24 |
+
@-webkit-keyframes spin {
|
| 25 |
+
0% { -webkit-transform: rotate(0deg); }
|
| 26 |
+
100% { -webkit-transform: rotate(360deg); }
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
@keyframes spin {
|
| 30 |
+
0% { transform: rotate(0deg); }
|
| 31 |
+
100% { transform: rotate(360deg); }
|
| 32 |
+
}
|
| 33 |
+
</style>
|
| 34 |
</head>
|
| 35 |
<body>
|
| 36 |
<h1>Upload CSV File</h1>
|
|
|
|
| 45 |
<input type="submit" value="Upload">
|
| 46 |
</form>
|
| 47 |
<div id="result"></div>
|
| 48 |
+
<div class="loader"></div>
|
| 49 |
|
| 50 |
<script>
|
| 51 |
document.getElementById('uploadForm').addEventListener('submit', function(event) {
|
| 52 |
event.preventDefault();
|
| 53 |
const form = new FormData(this);
|
| 54 |
+
const loader = document.querySelector('.loader');
|
| 55 |
+
loader.style.display = 'block'; // Показываем спиннер
|
| 56 |
+
|
| 57 |
fetch('/upload_csv', {
|
| 58 |
method: 'POST',
|
| 59 |
body: form
|
|
|
|
| 61 |
.then(response => response.json())
|
| 62 |
.then(data => {
|
| 63 |
document.getElementById('result').innerText = JSON.stringify(data, null, 2);
|
| 64 |
+
loader.style.display = 'none'; // Скрываем спиннер после завершения
|
| 65 |
})
|
| 66 |
.catch(error => {
|
| 67 |
console.error('Error:', error);
|
| 68 |
+
loader.style.display = 'none'; // Скрываем спиннер в случае ошибки
|
| 69 |
});
|
| 70 |
});
|
| 71 |
</script>
|