Kenneth Panio commited on
Commit
54ce9cc
·
1 Parent(s): 948031f

Create index.js

Browse files
Files changed (1) hide show
  1. index.js +24 -0
index.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const { exec } = require('child_process');
3
+
4
+ const app = express();
5
+ const port = 3000; // Adjust the port as needed
6
+
7
+ app.get('/', (req, res) => {
8
+ // Run your shell script using child_process
9
+ exec('./index.sh', (error, stdout, stderr) => {
10
+ if (error) {
11
+ console.error(`Error executing script: ${error}`);
12
+ return res.status(500).send('Internal Server Error');
13
+ }
14
+
15
+ console.log(`Script output: ${stdout}`);
16
+ console.error(`Script errors: ${stderr}`);
17
+
18
+ res.send('Script executed successfully.');
19
+ });
20
+ });
21
+
22
+ app.listen(port, () => {
23
+ console.log(`Express server is running on port ${port}`);
24
+ });