Skip to content

Commit

Permalink
Add UI
Browse files Browse the repository at this point in the history
  • Loading branch information
alundgard committed Mar 21, 2018
1 parent 0e9e074 commit 6e3dc67
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
25 changes: 17 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
@@ -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!'))
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Flex Data Mixer</title>
</head>
<body>
<h1>Flex Data Mixer</h1>

<form action="/gen" method="get">
<p>Number of dialogs to generate:<input type="text" name="dnum"></p>
<p>Name of the json file to generate:<input type="text" name="fname"></p>
<input type="submit">
</form>
</body>
</html>

0 comments on commit 6e3dc67

Please sign in to comment.