angularjs - Run python scripts from website -


i needed bit of guidance should read more on following problem:

i have few python scripts in folder on network drive run daily , want create website display scripts in form of list , when click on them want them running.

is there way solve problem angularjs ?

thanks help

okay, have small node server changed bit purpose, know isn't ideal server, should job. response on post request should depend on weather want fire python script or want output too.

from frontend, send post request data containing path python script or else, , change post case yourself.

use angular loop read through list, can json served static folder in directory.

this server not secure means , can cracked in short while, local scenario serves purpose.

also, if don't wanna use this, remember can server list endpoint page , populate html using ng-repeat , send post requests either script relative path or script name , handle paths @ backend, takeaway. sorry couldn't post 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){                             // error checking here , send response.                         })                         // or send response here.                         response.writehead(200);                         response.write("command fired.")                         response.end();                         break;             }         })     } })  server.listen(8002); console.log("listening "+"localhost".blue+" on port "+ "8002".green); server.on('error',function(err){     console.log('error happened: '+err.tostring()); }) 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -