DmitrMakeev
commited on
Commit
•
84301dc
1
Parent(s):
8fd95b6
Update upload_json.html
Browse files- upload_json.html +30 -6
upload_json.html
CHANGED
@@ -4,18 +4,42 @@
|
|
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
|
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>
|
21 |
-
|
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Upload JSON</title>
|
7 |
+
<script>
|
8 |
+
function showMessage(message) {
|
9 |
+
var messageDiv = document.getElementById('message');
|
10 |
+
messageDiv.innerText = message;
|
11 |
+
messageDiv.style.display = 'block';
|
12 |
+
}
|
13 |
+
|
14 |
+
function handleFormSubmit(event) {
|
15 |
+
event.preventDefault();
|
16 |
+
var formData = new FormData(event.target);
|
17 |
+
|
18 |
+
fetch('/upload_json', {
|
19 |
+
method: 'POST',
|
20 |
+
body: formData
|
21 |
+
})
|
22 |
+
.then(response => response.json())
|
23 |
+
.then(data => {
|
24 |
+
if (data.message) {
|
25 |
+
showMessage(data.message);
|
26 |
+
} else if (data.error) {
|
27 |
+
showMessage(data.error);
|
28 |
+
}
|
29 |
+
})
|
30 |
+
.catch(error => {
|
31 |
+
showMessage("An error occurred: " + error);
|
32 |
+
});
|
33 |
+
}
|
34 |
+
</script>
|
35 |
</head>
|
36 |
<body>
|
37 |
<h1>Upload JSON File</h1>
|
38 |
+
<form id="uploadForm" onsubmit="handleFormSubmit(event)" enctype="multipart/form-data">
|
39 |
<label for="file">Select JSON file:</label>
|
40 |
<input type="file" id="file" name="file" accept=".json" required><br><br>
|
|
|
|
|
|
|
|
|
41 |
<input type="submit" value="Upload">
|
42 |
</form>
|
43 |
+
<div id="message" style="display:none; margin-top:20px;"></div>
|
44 |
</body>
|
45 |
</html>
|
|