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.
- Run Python Script using PythonShell from Node.js
- Create a web server and run PHP script on it using Raspberry Pi
- Run python script from anywhere in linux
- How to Run a Python Script
- PyQt5 QSpinBox - Finding child using child type
- Nodejs | Automatic restart NodeJs server with nodemon
- Creating child process using fork() in Python
- Communication between Parent and Child process using pipe in Python
- Node.js Child Process
- Add a User in Linux using Python Script
- Deleting a User in Linux using Python Script
- Get Your System Information - Using Python Script
- How to Run Synchronous Queries using sync-sql Module in Node.js ?
- Python | Add Logging to a Python Script
- Run Length Encoding in Python
- How to run Python code on Google Colaboratory
- Python | Making program run faster
- Python | Longest Run of given Character in String
- Python IMDbPY – Getting run time of the series
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.