valky_host / index.html
Pepguy's picture
Update index.html
5542f62 verified
<!DOCTYPE html>
<html>
<head>
<title>Redis Test</title>
<style>
body {
font-family: sans-serif;
padding: 2rem;
background: #f0f0f0;
}
input, button {
padding: 0.5rem;
margin: 0.5rem 0;
display: block;
width: 100%;
max-width: 400px;
}
pre {
background: #222;
color: #0f0;
padding: 1rem;
overflow-x: auto;
}
</style>
</head>
<body>
<h1>Redis Test UI</h1>
<input id="key" placeholder="Key" />
<input id="value" placeholder="Value" />
<button onclick="save()">Save</button>
<button onclick="get()">Get</button>
<button onclick="del()">Delete</button>
<button onclick="all()">Get All</button>
<button onclick="backup()">Backup to Drive</button>
<pre id="output"></pre>
<script>
async function save() {
const key = document.getElementById('key').value;
const value = document.getElementById('value').value;
const res = await fetch('/save', {
method: 'POST',
body: JSON.stringify({ key, value }),
headers: { 'Content-Type': 'application/json' }
});
document.getElementById('output').textContent = await res.text();
}
async function get() {
const key = document.getElementById('key').value;
const res = await fetch('/get?key=' + encodeURIComponent(key));
document.getElementById('output').textContent = await res.text();
}
async function del() {
const key = document.getElementById('key').value;
const res = await fetch('/delete?key=' + encodeURIComponent(key), {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
document.getElementById('output').textContent = await res.text();
}
async function all() {
const res = await fetch('/all', {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
});
document.getElementById('output').textContent = JSON.stringify(await res.json(), null, 2);
}
async function backup() {
const res = await fetch('/backup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
document.getElementById('output').textContent = await res.text();
}
</script>
</body>
</html>