File size: 711 Bytes
f75e5eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
async function checkStatus() {
    const res = await fetch("/status");
    const data = await res.json();
    if (data.ready) {
        document.getElementById("loading").style.display = "none";
        document.getElementById("app").style.display = "block";
    } else {
        setTimeout(checkStatus, 2000);
    }
}

async function runQuery() {
    const sql = document.getElementById("sql").value;

    const res = await fetch("/query", {
        method: "POST",
        headers: {"Content-Type": "application/json"},
        body: JSON.stringify({sql})
    });

    const data = await res.json();
    document.getElementById("output").textContent =
        JSON.stringify(data, null, 2);
}

checkStatus();