Check python syntax within nodejs application

Sometimes , we need to check the python script syntax in a NodeJS application. For eg: a formular is stored in a database (via NodeJS application) as a python script syntax, then we use python eval() function to execute that python function.

We can use NodeJS child process to call to python (py_compile module) to check the syntax only (not exec)

Python code to check the syntax:

Here is the result:

Full code on github:

Hope this will help anyone facing with the same use case to me!