hmm: Serverseitiges JavaScript soll Serverseitiges Pythonscript ansprechen

Beitrag lesen

danke läuft!

var express = require('express');
var app = express();
var shell = require('shelljs')
//const addon = require('./build/Release/hello');

app.use(app.router);

app.use("/boot/css",  express.static(__dirname + '/boot/css'));
app.use("/boot/js", express.static(__dirname + '/boot/js'));
app.use("/boot/img",  express.static(__dirname + '/boot/img'));

app.get('/', function(req, res){
    res.sendfile('index.html', { root: __dirname + "/" } );
});

app.get('/app', function(req, res) {
     res.setHeader('Content-Type', 'application/json');
     var str = shell.exec('python test.py').stdout;
     console.log(str);
     res.send(JSON.stringify({ antwort: str}));//addon.hello()
 });
 
app.listen(8080);