Commit 4efb8638 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

refac

parent 8f8ce269
...@@ -138,18 +138,14 @@ ...@@ -138,18 +138,14 @@
}; };
const executePython = async (code) => { const executePython = async (code) => {
result = null;
stdout = null;
stderr = null;
executed = true; executed = true;
let pyodide = await loadPyodide({ let pyodide = await loadPyodide({
indexURL: '/pyodide/', indexURL: '/pyodide/',
stderr: (text) => {
console.log('An error occured:', text);
if (stderr) {
stderr += `${text}\n`;
} else {
stderr = `${text}\n`;
}
},
stdout: (text) => { stdout: (text) => {
console.log('Python output:', text); console.log('Python output:', text);
...@@ -158,14 +154,22 @@ ...@@ -158,14 +154,22 @@
} else { } else {
stdout = `${text}\n`; stdout = `${text}\n`;
} }
},
stderr: (text) => {
console.log('An error occured:', text);
if (stderr) {
stderr += `${text}\n`;
} else {
stderr = `${text}\n`;
}
} }
}); });
result = pyodide.runPython(code); result = pyodide.runPython(code);
console.log(result); console.log(result);
console.log(stderr);
console.log(stdout); console.log(stdout);
console.log(stderr);
}; };
$: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : ''; $: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : '';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment