-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (21 loc) · 703 Bytes
/
app.js
File metadata and controls
28 lines (21 loc) · 703 Bytes
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
const express = require('express')
const app = express()
const path = require('path')
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.get('/gen', (req, res) => {
const dnum = req.query.dnum;
const fname = req.query.fname;
const { spawn } = require('child_process');
const pyProg = spawn('python',['./mixer.py', dnum]);
var str = "";
pyProg.stdout.on('data', (data) => {
str += data.toString();
});
pyProg.on('close', (code) => {
res.set({"Content-Disposition":`attachment; filename=${fname}.json`});
res.send(str);
});
});
app.listen(4000, () => console.log('app listening on port 4000!'))