DmitrMakeev
commited on
Update j_upl_json.html
Browse files- j_upl_json.html +8 -47
j_upl_json.html
CHANGED
@@ -2,58 +2,19 @@
|
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
|
|
5 |
<title>Upload JSON</title>
|
6 |
</head>
|
7 |
<body>
|
8 |
-
<h1>Upload JSON
|
9 |
-
<form
|
10 |
-
<
|
11 |
-
<br><br>
|
12 |
<label for="verify_phone">Verify Phone Number:</label>
|
13 |
-
<input type="checkbox" id="verify_phone" name="verify_phone" value="1">
|
14 |
-
<br>
|
15 |
<label for="add_curator">Add Curator:</label>
|
16 |
-
<input type="checkbox" id="add_curator" name="add_curator" value="1">
|
17 |
-
<
|
18 |
-
<input type="submit" value="Upload JSON">
|
19 |
</form>
|
20 |
-
|
21 |
-
<script>
|
22 |
-
document.getElementById('json-file-input').addEventListener('change', function(event) {
|
23 |
-
const file = event.target.files[0];
|
24 |
-
if (file) {
|
25 |
-
const reader = new FileReader();
|
26 |
-
reader.onload = function(e) {
|
27 |
-
console.log('JSON File Content:', e.target.result);
|
28 |
-
};
|
29 |
-
reader.readAsText(file);
|
30 |
-
}
|
31 |
-
});
|
32 |
-
|
33 |
-
document.getElementById('json-upload-form').addEventListener('submit', function(event) {
|
34 |
-
event.preventDefault();
|
35 |
-
const file = document.getElementById('json-file-input').files[0];
|
36 |
-
if (file) {
|
37 |
-
const reader = new FileReader();
|
38 |
-
reader.onload = function(e) {
|
39 |
-
console.log('JSON File Content on Submit:', e.target.result);
|
40 |
-
// Create a formData object and send the request
|
41 |
-
const formData = new FormData();
|
42 |
-
formData.append('file', file);
|
43 |
-
formData.append('verify_phone', document.getElementById('verify_phone').checked ? '1' : '0');
|
44 |
-
formData.append('add_curator', document.getElementById('add_curator').checked ? '1' : '0');
|
45 |
-
|
46 |
-
fetch('/j_upload_json', {
|
47 |
-
method: 'POST',
|
48 |
-
body: formData
|
49 |
-
})
|
50 |
-
.then(response => response.json())
|
51 |
-
.then(data => console.log('Server response:', data))
|
52 |
-
.catch(error => console.error('Error:', error));
|
53 |
-
};
|
54 |
-
reader.readAsText(file);
|
55 |
-
}
|
56 |
-
});
|
57 |
-
</script>
|
58 |
</body>
|
59 |
</html>
|
|
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Upload JSON</title>
|
7 |
</head>
|
8 |
<body>
|
9 |
+
<h1>Upload JSON File</h1>
|
10 |
+
<form action="/upload_json" method="post" enctype="multipart/form-data">
|
11 |
+
<label for="file">Select JSON file:</label>
|
12 |
+
<input type="file" id="file" name="file" accept=".json" required><br><br>
|
13 |
<label for="verify_phone">Verify Phone Number:</label>
|
14 |
+
<input type="checkbox" id="verify_phone" name="verify_phone" value="1"><br><br>
|
|
|
15 |
<label for="add_curator">Add Curator:</label>
|
16 |
+
<input type="checkbox" id="add_curator" name="add_curator" value="1"><br><br>
|
17 |
+
<input type="submit" value="Upload">
|
|
|
18 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</body>
|
20 |
</html>
|