title: NodeJs: Get output of python-shell to send back to client
body: <p>I am trying to create a website where a user can submit python code, it gets sent to my server to be executed and I send back the results to the client. Currently I am using a NodeJs server and need to run the python code from there. To do this, I am using Python-shell like so:</p>
  
  <pre><code>const runPy = async (code) =&gt; {
     const options = {
        mode: 'text',
        pythonOptions: ['-u'],
        scriptPath: path.join(__dirname, '../'),
        args: [code],
     };
  
    const result = await PythonShell.run('script.py', options, (err, results) =&gt; {
       if (err) throw err;
       return results; &lt;----- HOW DO I RETURN THIS
    });
    console.log(result.stdout);
    return result;
  };
  </code></pre>
  
  <p>I understand I can <code>console.log()</code> the results in the <code>PythonShell.run()</code> but is there a way to return the results from my <code>runPy</code> function to then be manipulated and sent back to the client?</p>