How To Pass JavaScript Variables To Python Using JSON

preview_player
Показать описание
Are you a website developer and want to learn how to pass JavaScript variables to #python using JSON? Here in this video, we create an HTML page that captures data entered into a set of boxes and then using JSON and AJAX passed them over to Python and create a Python dictionary from the data passed.

⏲⏲⏲TIMESTAMPS⏲⏲⏲
00:00 Intro
00:35 Capture JSON data
06:25 Use AJAX to pass data
08:16 Process the data in Python
13:38 Subscribe

################ Lets be Social! ##################

#AJAX #JSON #javascript #flask #pythonflask #dataanalyticsireland
Рекомендации по теме
Комментарии
Автор

Hi! Thanks a lot for the useful video! Since I have very little experience with JavaScript, I have a question to understand the logic behind. Why are you doing 'stringify' on both the 'dict values' and the already stringified dict values in the ajax call? Could you, for example, just pass "s" as the data? And if that's indeed possible, how would that change the code in the Python file?

arminegaribyan
Автор

Thanks a lot you saved me for my Engineer project !

KaceCM
Автор

hi! I found this solution wonderful, thanks a lot for this kind of content on internet.
I have a question, I have a app on shiny python, how can I replice this on that?

ferpib
Автор

Happy New Year! Wishing you YouTube success in 2022.

BrandonJacobson
Автор

I really love this tutorial as this is a question I was asking myself many times and you just solved it. But I would love to see the reverse like how do you pass data back from python to that same html page. like how would you populate a list in the html page from data processed from python?

dorson
Автор

Hey I was wondering where the url: "/test" in the Ajax portion is pointing to? My url doesn't seem to be making a link. Is it the function in the py file?

This is my file setup

> static
app.js
style.css
> Images
> templates
index.html
app.py

tannerormanoski
Автор

I don't know if you will see this but how did you run the Flask server. I've tried so many things and my code is an exact copy of yours but I feel like I'm setting up my flask environment wrong but you never showed us how you started the server so I don't know if I've started this wrong or not. What commands did you put in the terminal window to start the virtual environment to make this work.

meekermotions
Автор

Thanks for the video! My app is unable to locate my template index.html. My folder setup is similar to your where I have my app.py in a venv folder and my idea.html in a template folder. My app route is the same as yours as well.

tannerormanoski
Автор

I tried to run the code but why always give me lazy loading and then shows Error: Could not import 'app'.?

muhammadyezabaihaqi
Автор

Hey, Thanks for the video but im getting this error:-
Did not attempt to load JSON data because the request Content-Type was not 'application/json'.

atharvachopde
Автор

Thank you so much for this video🙌🏽

But sir my print(output) in the python code is showing None. I am trying to print a JavaScript variable in my terminal using flask (not getting a html value), please help🙏

musaopaluwa
Автор


files path are as follows:
index.html : localhost/index.html
app.py : localhost/venv/scripts/app.py

gaurangsolanki
visit shbcf.ru