Tutorial
Adding and running an executable to the backend
- Add a route to index.js to handle a call.
- An example of this is router.get('/vasp', function(req, res, next) {…}
- '/vasp' is the name of the call from the frontend – this can be called anything.
- Create a child that holds the executable call.
- Use const child = spawn(…) 1. Use 'executables' path for the last parameter of spawn() to point to the correct path for executables.
- Must add child.on('error') to avoid errors.
- Can also add child.on('close'), child.stdout.on(), child.stderr.on() for debugging.
- In /views folder, add a reference to the route call from above.
- For example, if route call is '/vasp', then form(action='/vasp' method ='POST')
- Add your executable files to /executables
- The call to the executable will be exactly what your call is from the terminal. This would be the easiest way to run the executable. For example,
constchild = spawn('python', ['./DiffBond\_v2.py', '-i', '../public/uploads/1brs.pdb', '-m', 'i'], executables)