How to Call a Python Script From JavaScript (AND PASS DATA BETWEEN)

preview_player
Показать описание
In this video I'll show you how you can call a Python script from JavaScript and even pass data between them! I thought it was an interesting idea, so here it is. So if you have ever wondered how to execute Python from JavaScript then here it is.

Thanks for watching, if you want to learn more about JavaScript or Python please check out my other videos and the links below!

👇👇👇

––––––––––––––––––––––––––––––

DISCLAIMER: Links included in this description might be affiliate links. If you purchase a product or service with the links that I provide I may receive a small commission. There is no additional charge to you! Thank you for supporting me so I can continue to provide you with free content each week!
Рекомендации по теме
Комментарии
Автор

finally! a way to communicate between javascript and python without having to use flask or some other! thank you so much for this!

rysa.tarts
Автор

from all the methods i found this is the best one.. Big thanks <3

benzinaaziz
Автор

Thank you for helping our project work✨

CATCHZY
Автор

Can you talk about performance? I am using this method to run a heavy python app that generates an image. My server is running locally on node js. This server has a restful API that when a client sends a POST request, the api will run a python script to get a photo and then return the url of the photo that it has selected.

redbeardhomes
Автор

I don't how to thank you, This video helped me to complete our project.

SMK
Автор

Error: ReferenceError: require is not defined. it doesnt work on a web browser

datkeks
Автор

Hello is it possible to send an image file from javascript to be processed to a python script? and also is it possible to return an image file after back to javascript?

jeremiahmarimon
Автор

If you're getting the error, "Error: spawn python ENOENT" try passing 'python3' argument instead of 'python' when running spawner:

const python_process = spawner('python3', ['./python.py', dataout]);

away
Автор

hi, i didn't understand a little detail:
what does the last line in the python file do? (I'm referring to "sys.stdout.flush()") does it return the actual return value of the python script or is the value printed out the one that gets returned to the initial JS file?

donatellodonini
Автор

Hi! Thanks to you I have learned something new and this is interesting but I am wondering if we are able to get data from python in a js script, can we do vice-versa? I mean, can we get data from JavaScript in a Python script?

If yes, can you show us how to do that as well, please?

orekihoutarou
Автор

How can we get tokens who generate with javascript at websites ?

AshahaSjssj
Автор

When i run the code the result is "Data sent to python script: { data_sent: 'Send this to python script.', data_returned: undefined }" i dont know why i can't received the data from python
(i am using vscode on Windows)

snupi
Автор

how to pass a specific python output to the javascript program, if there is mutliple print output on the python program

humaidahmedabuzinjal
Автор

I'm new to coding and there is something I want to code on python but is only taught on java from here can I start writing the java code on left and all that will automatically be converted into python? If I'm right just checking to 100% confirm.

kabeyatimothymanasse
Автор

hi, i was trying to put this on my website as a function on button click. when i clicked it, it said that "child_process" has not loaded in yet. can u help me with that? im sorry im new

AnonymousW
Автор

In the case of a deployment to aws/azure cloud, how will it be done since they are two seperate backend language

abubakardev
Автор

I taking 'requiest not defined' erorr :/

lavizlay
Автор

I'm not sure what I did, but for some reason I was able to get this to work once, and then it stopped returning data to Node. Running the script raw from Terminal works, but running from Node using the method shown in the video does not do anything. It gives no errors, it just does not run the "python_process.stdout.on('data', (data..." part. The code itself just kinda skips it or something.
Some say it's a buffering issue, but I am not sure how to turn off buffering using the spawner method

Piipperi
Автор

That is cool! I thought you could only pass data between PHP and JavaScript? Had no idea you could do the same with Python and JavaScript?

DevlogBill
Автор

alright lemme grab a fircking magnifier i can't see the code

KalanaNethsara