-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |