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
- Nodejs | Automatic restart NodeJs server with nodemon
- How to Run a Python Script
- Run python script from anywhere in linux
- Schedule a Python Script on PythonAnywhere
- Get directory of current Python script
- Python Script to Restart Computer
- Python Script to Shutdown Computer
- Convert Python Script to .exe File
- Python Script to Logout Computer
- Python | Accepting Script Input
- Autorun a Python script on windows startup
- Python | Add Logging to a Python Script
- Node.js | script.createCachedData() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.