Spaces:
Running
Running
File size: 2,314 Bytes
c4786c3 fc849ba c4786c3 fc849ba 5542f62 fc849ba c4786c3 fc849ba c4786c3 |
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 |
<!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> |