Skip to content

Commit

Permalink
live.js: Use execFile rather than invoking a shell to call live.py
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-dyfis-net committed Aug 10, 2023
1 parent f669883 commit cb59879
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lmql/ui/live/live.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const io = require('socket.io')(server, {
origin: '*',
}
})
const exec = require('child_process').exec;
const execFile = require('child_process').execFile;
const spawn = require('child_process').spawn

let outputs = {};
Expand All @@ -30,7 +30,7 @@ io.on('connection', s => {
const app_arguments = request.app_arguments;

// run "python live.py endpoints" and get output lines as array
exec(`python live.py endpoints ${app_name}`, (err, stdout, stderr) => {
execFile(`python`, [`live.py`, `endpoints`, app_name], (err, stdout, stderr) => {
if (err) {
console.log(err);
s.emit("app-error", stdout + stderr)
Expand Down Expand Up @@ -121,7 +121,7 @@ app.get('/app/:app_name', (req, res) => {
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
let html = fs.readFileSync(path.join(__dirname, 'base/index.html'), {encoding: 'utf8'})

exec(`python live.py client-html ${app_name}`, (err, stdout, stderr) => {
execFile(`python`, [`live.py`, `client-html`, app_name], (err, stdout, stderr) => {
if (err) {
console.log(err);
res.send(html.replace("<<<CLIENT_HTML>>>", "Failed to load app html for app."))
Expand All @@ -135,7 +135,7 @@ app.get('/app/:app_name', (req, res) => {
app.get('/app/:app_name/app-client.js', (req, res) => {
const app_name = req.params.app_name;
// run "python live.py endpoints" and get output lines as array
exec(`python live.py client-script ${app_name}`, (err, stdout, stderr) => {
execFile(`python`, [`live.py`, `client-script`, app_name], (err, stdout, stderr) => {
if (err) {
console.log(err);
res.send("")
Expand Down

0 comments on commit cb59879

Please sign in to comment.