-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (35 loc) · 1.24 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const express = require('express');
const path = require('path');
const { exec } = require('child_process'); // Import exec to run shell commands
const app = express();
const port = 3000;
// Serve static files (HTML, CSS, JS) from the 'public' directory
app.use(express.static(path.join(__dirname, 'public')));
// Home route
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Route to execute Streamlit app
app.get('/runScrape', (req, res) => {
exec('python C:/RVCE(2023-27)/3rd_sem/EL/hack/Scrapy_scheme/infogov/infogov/spiders/app.py', (err, stdout, stderr) => {
if (err) {
res.send(`Error running streamlit: ${stderr}`);
return;
}
res.send(`Streamlit app output: ${stdout}`);
});
});
// Route to execute Python app
app.get('/runPython', (req, res) => {
exec('"python" "C:/RVCE(2023-27)/3rd_sem/EL/hack/medicine_prototype_01/gui-med.py"', (err, stdout, stderr) => {
if (err) {
res.send(`Error running Python app: ${stderr}`);
return;
}
res.send(`Python app output: ${stdout}`);
});
});
// Start the server
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}/`);
});