I am trying to create a website in Node.js. Though, as I am taking a course on how to use Artificial Intelligence and would like to implement such into my program. Therefore, I was wondering if it was feasible to connect Python Spyder to a Node.js based web application with somewhat ease.
Question posted in Artificial Intelligence
ChatGBT is becoming a world-wide phenomena, try it out here.
ChatGBT is becoming a world-wide phenomena, try it out here.
2
Answers
There are 2 ways i am aware of which you can do this
1) Use child_process library
You can check this article if you want step by step guide.
https://www.geeksforgeeks.org/run-python-script-node-js-using-child-process-spawn-method/
2) Better method would be to create a API which you can later call using AJAX or whichever library you prefer. You can use microframework such as flask to create a server which then you can call using NodeJs.
Tutorial to convert your machine learning code to API:
https://towardsdatascience.com/publishing-machine-learning-api-with-python-flask-98be46fb2440
Or you can just pass a list or dictionary object. https://flaviocopes.com/node-axios/ you can learn more about axios here.
Yes. That is possible. There are a few ways you can do this. You can use the child_process library, as mentioned above. Or, you can have a Python API that takes care of the AI stuff, which your Node app communicates with.
The latter example is what I prefer as most my projects run on containers as micro services on Kubernates.