async function run() { const code = document.getElementById("code").value; const res = await fetch("/run", { method: "POST", headers: {"Content-Type":"application/json"}, body: JSON.stringify({ token: localStorage.getItem("token"), code }) }); const data = await res.json(); document.getElementById("out").innerText = data.output || data.error; } async function ai() { const prompt = document.getElementById("code").value; const res = await fetch("/ai", { method: "POST", headers: {"Content-Type":"application/json"}, body: JSON.stringify({ token: localStorage.getItem("token"), prompt: "Fix this code:\n" + prompt }) }); const data = await res.json(); document.getElementById("code").value = data.result; }