diff --git a/app.js b/app.js index 2858dcf..b8d92ab 100644 --- a/app.js +++ b/app.js @@ -1,19 +1,28 @@ const express = require('express') const app = express() +const path = require('path') app.get('/', (req, res) => { + res.sendFile(path.join(__dirname, 'index.html')); +}); - const num = req.query.num; - const { spawn } = require('child_process'); - const pyProg = spawn('python',['./mixer.py', num]); +app.get('/gen', (req, res) => { - pyProg.stdout.on('data', function(data) { + const dnum = req.query.dnum; + const fname = req.query.fname; + const { spawn } = require('child_process'); + const pyProg = spawn('python',['./mixer.py', dnum]); + var str = ""; - // console.log(data.toString()); - res.write(data); - // res.end('end'); + 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!')) \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..179f295 --- /dev/null +++ b/index.html @@ -0,0 +1,15 @@ + + + +Flex Data Mixer + + +

Flex Data Mixer

+ +
+

Number of dialogs to generate:

+

Name of the json file to generate:

+ +
+ + \ No newline at end of file