This commit is contained in:
Timothy J. Baek 2024-05-16 19:22:10 -10:00
parent 8f8ce26948
commit 4efb8638ff

View File

@ -138,18 +138,14 @@
};
const executePython = async (code) => {
result = null;
stdout = null;
stderr = null;
executed = true;
let pyodide = await loadPyodide({
indexURL: '/pyodide/',
stderr: (text) => {
console.log('An error occured:', text);
if (stderr) {
stderr += `${text}\n`;
} else {
stderr = `${text}\n`;
}
},
stdout: (text) => {
console.log('Python output:', text);
@ -158,14 +154,22 @@
} else {
stdout = `${text}\n`;
}
},
stderr: (text) => {
console.log('An error occured:', text);
if (stderr) {
stderr += `${text}\n`;
} else {
stderr = `${text}\n`;
}
}
});
result = pyodide.runPython(code);
console.log(result);
console.log(stderr);
console.log(stdout);
console.log(stderr);
};
$: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : '';