-
Notifications
You must be signed in to change notification settings - Fork 0
/
sec.html
88 lines (84 loc) · 3.17 KB
/
sec.html
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
88
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>File Manager</title>
</head>
<body>
<h1>File Manager</h1>
<form id="login-form">
<label for="password1">Password 1:</label>
<input type="password" id="password1" name="password1"><br>
<label for="password2">Password 2:</label>
<input type="password" id="password2" name="password2"><br>
<button type="submit">Login</button>
</form>
<div id="file-manager" style="display:none;">
<h2>Upload File</h2>
<input type="file" id="fileInput"><br>
<button id="uploadButton">Upload</button>
<h2>Files</h2>
<ul id="fileList"></ul>
</div>
<script>
document.getElementById('login-form').addEventListener('submit', function(event) {
event.preventDefault();
const password1 = document.getElementById('password1').value;
const password2 = document.getElementById('password2').value;
fetch('https://silasmc.duckdns.org:8585/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({password1, password2})
})
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById('login-form').style.display = 'none';
document.getElementById('file-manager').style.display = 'block';
loadFiles();
} else {
alert('Invalid credentials');
}
});
});
document.getElementById('uploadButton').addEventListener('click', function() {
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
const formData = new FormData();
formData.append('file', file);
fetch('https://silasmc.duckdns.org:8585/upload', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('File uploaded');
loadFiles();
} else {
alert('File upload failed');
}
});
});
function loadFiles() {
fetch('https://silasmc.duckdns.org:8585/files')
.then(response => response.json())
.then(files => {
const fileList = document.getElementById('fileList');
fileList.innerHTML = '';
files.forEach(file => {
const li = document.createElement('li');
const link = document.createElement('a');
link.href = 'https://silasmc.duckdns.org:8585/download/' + file;
link.textContent = file;
li.appendChild(link);
fileList.appendChild(li);
});
});
}
</script>
</body>
</html>