Spaces:
Sleeping
Sleeping
Create settings.html
Browse files- settings.html +57 -2
settings.html
CHANGED
|
@@ -1,9 +1,64 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
<
|
|
|
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
</body>
|
| 9 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>Settings</title>
|
| 6 |
+
</head>
|
| 7 |
<body>
|
| 8 |
+
<h1>Settings</h1>
|
| 9 |
+
<form id="settingsForm">
|
| 10 |
+
<label for="vk_key">VK Key:</label>
|
| 11 |
+
<input type="text" id="vk_key" name="vk_key"><br><br>
|
| 12 |
|
| 13 |
+
<label for="telegram_key">Telegram Key:</label>
|
| 14 |
+
<input type="text" id="telegram_key" name="telegram_key"><br><br>
|
| 15 |
|
| 16 |
+
<label for="other_setting">Other Setting:</label>
|
| 17 |
+
<input type="text" id="other_setting" name="other_setting"><br><br>
|
| 18 |
|
| 19 |
+
<button type="button" onclick="saveSettings()">Save</button>
|
| 20 |
+
</form>
|
| 21 |
+
|
| 22 |
+
<script>
|
| 23 |
+
function loadSettings() {
|
| 24 |
+
fetch('/settings', {
|
| 25 |
+
method: 'GET'
|
| 26 |
+
})
|
| 27 |
+
.then(response => response.json())
|
| 28 |
+
.then(data => {
|
| 29 |
+
document.getElementById('vk_key').value = data.vk_key;
|
| 30 |
+
document.getElementById('telegram_key').value = data.telegram_key;
|
| 31 |
+
document.getElementById('other_setting').value = data.other_setting;
|
| 32 |
+
})
|
| 33 |
+
.catch(error => console.error('Error:', error));
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
function saveSettings() {
|
| 37 |
+
const form = document.getElementById('settingsForm');
|
| 38 |
+
const formData = new FormData(form);
|
| 39 |
+
const data = {};
|
| 40 |
+
|
| 41 |
+
formData.forEach((value, key) => {
|
| 42 |
+
if (value !== '') {
|
| 43 |
+
data[key] = value;
|
| 44 |
+
}
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
fetch('/settings', {
|
| 48 |
+
method: 'POST',
|
| 49 |
+
headers: {
|
| 50 |
+
'Content-Type': 'application/json'
|
| 51 |
+
},
|
| 52 |
+
body: JSON.stringify(data)
|
| 53 |
+
})
|
| 54 |
+
.then(response => response.json())
|
| 55 |
+
.then(data => {
|
| 56 |
+
console.log('Success:', data);
|
| 57 |
+
})
|
| 58 |
+
.catch(error => console.error('Error:', error));
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
window.onload = loadSettings;
|
| 62 |
+
</script>
|
| 63 |
</body>
|
| 64 |
</html>
|