Node.js is one of the most adopted web development technologies but it lacks support for machine learning, deep learning and artificial intelligence libraries. Luckily, Python supports all these and many more other features. Django Framework for Python can utilize this functionality of Python and can provide support for building new age web application using machine learning and Artificial Intelligence.
For those developers who are not familiar with Django Framework but use Node JS framework can also benefit from Python using child process module for Node JS.
child_process.spawn(): This method helps us to spawn child process asynchronously.
Let’s create a simple Python script that will take two command line arguments as a first name and last name then display them. Later we’ll run that script from Node JS application and display output in the browser window.
Python script :
Node JS server code :
After saving the Python script and server script code, run the code from its source folder by following command :
Access the application through link :
localhost:3000/name?firstname="Enter first name"&lastname="Enter last name" For e g. : localhost:3000/name?firstname=Ram&lastname=Sharma
- This method can be used in alternative to REST-APIs.
- Machine learning modules can be implemented in Python and then utilize them in web app using this method.
- Creating child process using fork() in Python
- Communication between Parent and Child process using pipe in Python
- PyQt5 QSpinBox - Finding child using child type
- Nodejs | Automatic restart NodeJs server with nodemon
- How to Run a Python Script
- Run python script from anywhere in linux
- Node.js | script.runInThisContext() Method
- Node.js | Constructor: new vm.Script() Method
- Node.js | script.runInNewContext() Method
- Node.js | script.runInContext() Method
- Node.js | script.createCachedData() Method
- Convert Python Script to .exe File
- Python Script to Restart Computer
- Python Script to Logout Computer
- Python Script to Shutdown Computer
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.