|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<title>Settings</title> |
|
</head> |
|
<body> |
|
<h1>Settings</h1> |
|
<form id="settingsForm"> |
|
<label for="api_key_sys">api_key_sys:</label> |
|
<input type="text" id="api_key_sys" name="api_key_sys"><br><br> |
|
|
|
<label for="ALLOWED_ORIGIN">ALLOWED_ORIGIN:</label> |
|
<input type="text" id="ALLOWED_ORIGIN" name="ALLOWED_ORIGIN"><br><br> |
|
|
|
<label for="vk_api_key">vk_api_key:</label> |
|
<input type="text" id="vk_api_key" name="vk_api_key"><br><br> |
|
|
|
<label for="crypto_key_sys">crypto_key_sys:</label> |
|
<input type="text" id="crypto_key_sys" name="crypto_key_sys"><br><br> |
|
|
|
<label for="vk_api_key">vk_api_key:</label> |
|
<input type="text" id="vk_api_key" name="crypto_key_sys"><br><br> |
|
|
|
|
|
|
|
<button type="button" onclick="saveSettings()">Save</button> |
|
</form> |
|
|
|
<script> |
|
function loadSettings() { |
|
fetch('/settings', { |
|
method: 'GET' |
|
}) |
|
.then(response => response.json()) |
|
.then(data => { |
|
document.getElementById('api_key_sys').value = data.api_key_sys; |
|
document.getElementById('ALLOWED_ORIGIN').value = data.ALLOWED_ORIGIN; |
|
document.getElementById('vk_api_key').value = data.vk_api_key; |
|
document.getElementById('crypto_key_sys').value = data.crypto_key_sys; |
|
document.getElementById('vk_api_key').value = data.vk_api_key; |
|
}) |
|
.catch(error => console.error('Error:', error)); |
|
} |
|
|
|
function saveSettings() { |
|
const form = document.getElementById('settingsForm'); |
|
const formData = new FormData(form); |
|
const data = {}; |
|
|
|
formData.forEach((value, key) => { |
|
if (value !== '') { |
|
data[key] = value; |
|
} |
|
}); |
|
|
|
fetch('/settings', { |
|
method: 'POST', |
|
headers: { |
|
'Content-Type': 'application/json' |
|
}, |
|
body: JSON.stringify(data) |
|
}) |
|
.then(response => response.json()) |
|
.then(data => { |
|
console.log('Success:', data); |
|
}) |
|
.catch(error => console.error('Error:', error)); |
|
} |
|
|
|
window.onload = loadSettings; |
|
</script> |
|
</body> |
|
</html> |