You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
742 B
JavaScript

"use strict";
let { PythonShell } = require("python-shell");
/**
* Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#core-controllers)
* to customize this controller
*/
module.exports = {
async findOne(ctx) {
const { name } = ctx.params;
const entity = await strapi.services.function.findOne({ name });
let script = () => {
return new Promise((resolve, reject) => {
PythonShell.run(
"./public" + entity.script.url,
null,
function (err, results) {
if (err) throw err;
resolve(results);
}
);
});
};
let output = await script();
return entity;
},
};