Okay, So I have a small node server I which I changed a bit for your purpose, I know this isn't an ideal server, but this should do the job. The response on the post request should depend on weather you just want to fire the python script or you want its output too.
From frontend, send a post request with data containing the path to the python script or something else, and change the post case yourself.
Use an angular loop to read through the list, which can be a json served from the static folder in your directory.
This server is not secure by any means and probably can be cracked into in a short while, but for a local scenario it serves the purpose.
Also, if you don't wanna use this, then remember that you can server up the list from an endpoint to the page and populate the HTML using ng-repeat and then send post requests with either the script relative path or the script name and handle paths at the backend, this will be the takeaway. Sorry couldn't post anything for frontend.
var http = require('http');
var fs = require('fs');
var url = require('url');
var colors = require('colors');
var exec = require('child_process').exec;
var staticReg = /^\/static\/\w+\.\w+$/;;
var server = http.createServer(function(request, response){
var url_parts = url.parse(request.url)
if (request.method=="GET"){
process.stdout.write("GET :: ".green + url_parts.path.yellow)
if(staticReg.test(url_parts.path)){
if (fs.existsSync("."+url_parts.path)){
response.writeHead(200)
response.write(fs.readFileSync("."+url_parts.path))
response.end()
process.stdout.write(" :: 200\n".green)
}
else{
response.writeHead(404)
response.end()
process.stdout.write(" :: 404\n".red)
}
return
}
switch (url_parts.path){
case "/":
process.stdout.write(" :: 200\n".green)
var home = fs.readFileSync("./index.html")
response.writeHead(200);
response.write(home);
response.end();
break;
default :
process.stdout.write(" :: 404\n".red)
response.writeHead(404);
response.write("404 not found")
response.end();
break;
}
}
if (request.method=="POST"){
process.stdout.write("POST :: ".green + url_parts.path.yellow)
var body = '';
request.on('data',function(data){
body+=data;
});
request.on('end', function(){
switch(url_parts.path){
case "/fire/":
body=JSON.parse(body)
process.stdout.write(" :: 200\n".green)
command='python '+body["script_path"]
exec(command,function callback(error, stdout, stderr){
// Do error checking here and send response.
})
// Or send response here.
response.writeHead(200);
response.write("Command fired.")
response.end();
break;
}
})
}
})
server.listen(8002);
console.log("Listening to "+"localhost".blue+" on port "+ "8002".green);
server.on('error',function(err){
console.log('Error happened: '+err.toString());
})