|
<!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> |
|
</head> |
|
<body> |
|
<h1>Upload CSV File</h1> |
|
<form id="uploadForm" enctype="multipart/form-data" method="post"> |
|
<input type="file" name="file" accept=".csv"> |
|
<input type="submit" value="Upload"> |
|
</form> |
|
<div id="result"></div> |
|
|
|
<script> |
|
document.getElementById('uploadForm').addEventListener('submit', function(event) { |
|
event.preventDefault(); |
|
const form = new FormData(this); |
|
fetch('/upload_csv', { |
|
method: 'POST', |
|
body: form |
|
}) |
|
.then(response => response.json()) |
|
.then(data => { |
|
document.getElementById('result').innerText = JSON.stringify(data, null, 2); |
|
}) |
|
.catch(error => { |
|
console.error('Error:', error); |
|
}); |
|
}); |
|
</script> |
|
</body> |
|
</html> |