-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (32 loc) · 1.02 KB
/
app.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
const express = require('express');
const bodyParser = require("body-parser");
var {PythonShell} = require('python-shell');
const path = require('path');
const app = express();
const port = process.env.PORT;
app.use(express.static(path.join(__dirname, 'public/css')));
app.use(bodyParser.urlencoded({
extended:true
}));
app.get('/',function(req,res){
res.sendFile(__dirname + "/index.html");
});
app.post('/', (req, res) => {
let videolink=req.body.vlink;
var options = {
mode: 'text',
pythonPath: '/usr/bin/python3',
pythonOptions: ['-u'],
scriptPath: __dirname,
args: [videolink]
};
PythonShell.run('script.py', options, function (err, results) {
if (err) throw err;
// results is an array consisting of messages collected during execution
console.log('results: %j', results);
res.download(String(results[0]));
//res.sendFile(__dirname +"/downloaded.html");
});
})
app.listen(port, () => console.log(`Example app listening on port
${port}!`))