-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (27 loc) · 878 Bytes
/
index.js
File metadata and controls
33 lines (27 loc) · 878 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
29
30
31
32
33
const express = require('express')
var bodyParser = require("body-parser");
var path = '/Users/gaganhegde/Desktop/trioli/newfile.py'
const app = express()
var fs = require("fs");
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get('/',(req,res)=>{
const{spawn} = require('child_process');
const pyProg = spawn('python',['newfile.py']);
console.log(req.params);
pyProg.stdout.on('data', function(data){
console.log(data.toString());
res.write(data);
res.end();
})
})
app.post('/',(req,res)=>{
var portion = req.body.code;
fs.writeFile('newfile.py', portion, function (err) {
if (err)
return console.log(err);
console.log('File Written');
});
res.send("done");
})
app.listen(3003,()=> console.log("active on Port 3003!"));