fca-fb / index.js
Kenneth Panio
Create index.js
54ce9cc
raw
history blame contribute delete
658 Bytes
const express = require('express');
const { exec } = require('child_process');
const app = express();
const port = 3000; // Adjust the port as needed
app.get('/', (req, res) => {
// Run your shell script using child_process
exec('./index.sh', (error, stdout, stderr) => {
if (error) {
console.error(`Error executing script: ${error}`);
return res.status(500).send('Internal Server Error');
}
console.log(`Script output: ${stdout}`);
console.error(`Script errors: ${stderr}`);
res.send('Script executed successfully.');
});
});
app.listen(port, () => {
console.log(`Express server is running on port ${port}`);
});