How to Pass Python Variables To JavaScript

preview_player
Показать описание


⏰⏰⏰TimeStamps ⏰⏰⏰
Intro 00:00
Subscribe 12:00

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

#Ptyhon #Javascript #dataanalyticsireland
Рекомендации по теме
Комментарии
Автор

Nice. Thank you so much. this is a very useful video. What would be the process to create a list of tasks in python and populate that list in the web UI so everyone who connects to the flask server can see the list and cancel any item they do not want in the list and have python handle that in the background?

dorson
Автор

Absolutely brilliant videos mate. Cant find anyone who explains as good

josephmanning
Автор

hi thanks for the video. here you have passed variables from python to html and then from html to javascript. kindly explain how we can pass variable from python directly to the javascript. My requirement is to get the value of lable2 that depends on the value of lable1 (when it is selected)

CHIKOO
Автор

also, it looks like we need to load the python file first and then click on the link in the terminal to open the web UI over 127.0.0.1. if we were to have a real dns name for the site so everyone could access, could just go to that url and load the python script from there instead of running the python script from the python itself?

dorson
Автор

there is an error in {{}}, my code doesnt accept it

braanajjar
Автор

Basically, what I am trying to do is the following: I sent some jobs to be done on a backend server which came back with a response. That response, i am trying to use it and update the html page without reloading it. How would i take the json response to update the html page to show it was successful or failed?

dorson
Автор

Do you have a way to update a website section from flask without refreshing the page?

dorson
Автор

Thx for the info. I tried your code and I always receive this error in the line:
var selectvalue = document.getElementById("selectvalue"), test={{name|tojson}};
the error is "declaration assignment expected". Some people said to replace the {{}} by (()) or remove them completely, but that did not make a difference. The drop down opened in the html page, but nothing in it. Despite everything is the same.

Any idea?

Thx in advance.
Dorson

dorson
Автор

There are moments when I barelyunderstandd what you are saying.

omojjegomosc
Автор

I had a problem too.

This is my .py code:

from flask import Flask, render_template

app = Flask(__name__)

@app.route("/")
def index():
name = ['Joe', 'John', 'Jim', 'Paul', 'Niall', 'Tom']
return render_template("index.html", name=name)

if __name__ == "__main__":
app.run(debug=True)



But it gives an error on this line:

var selectvalue = document.getElementById("selectvalue"), test = {{name | tojson}};


It doesn't recognize the {} nor the | in the part: test = {{name | tojson}}; ...

igormartins
visit shbcf.ru