Skip to content

execute()

Simon Köck edited this page Mar 30, 2021 · 4 revisions
const cee = require("code-execution-engine");

cee
  .execute("print('Hello World')", cee.languages.PYTHON3, [], "", {
    timeout: 5,
  })
  .then((result) => {
    console.log(result);
  })
  .catch((error) => {
    console.error(error);
  });

execute(input, language, [args], [stdin], [options]) → Promise<String>

Returns the result (stdout) of the executed code. If stderr is not empty, an exception will be thrown with the content of stderr.

input: string – The source code that should be executed.

language: cee.Language – Pass the language the code is written in, for example, cee.languages.PYTHON3. Supported Lanuages

args: string[] - Command-Line arguments that are passed to the script

stdin: string - Set the stdin for the script

options: IExecuteOptions

      timeout: number - Max execution time of the script. This option doesn't work on windows. Defaults to 5