-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
87 lines (76 loc) · 2.18 KB
/
Copy pathtest.html
File metadata and controls
87 lines (76 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<title>CSV Upload Test</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 50px auto;
padding: 20px;
}
button {
background: #4caf50;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
font-size: 16px;
}
button:hover {
background: #45a049;
}
#result {
background: #f4f4f4;
padding: 15px;
margin-top: 20px;
border-radius: 5px;
white-space: pre-wrap;
}
</style>
</head>
<body>
<h1>Test CSV Upload</h1>
<input type="file" id="csvFile" accept=".csv" />
<button onclick="uploadCSV()">Upload & Process</button>
<div id="status"></div>
<pre id="result"></pre>
<script>
async function uploadCSV() {
const fileInput = document.getElementById('csvFile');
const file = fileInput.files[0];
if (!file) {
alert('Please select a CSV file first!');
return;
}
const webhookURL = 'PROD_WEBHOOK';
const formData = new FormData();
formData.append('data', file);
document.getElementById('status').textContent = '⏳ Processing...';
document.getElementById('result').textContent = '';
try {
const response = await fetch(webhookURL, {
method: 'POST',
body: formData,
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const result = await response.json();
const data = Array.isArray(result) ? result[0] : result;
document.getElementById('status').textContent = '✅ Success!';
document.getElementById('result').textContent = JSON.stringify(
data,
null,
2
);
} catch (error) {
document.getElementById('status').textContent = '❌ Error!';
document.getElementById('result').textContent =
'Error: ' + error.message;
console.error('Upload error:', error);
}
}
</script>
</body>
</html>