How can i Pass Variable from flask) o HTML without render template? How can i Pass Variable from flask) o HTML without render template? flask flask

How can i Pass Variable from flask) o HTML without render template?


FLASK APP.py

#This route accepts request against the url http://domain_name/change_label#You could add the argument, method=["POST"],<br>So the route only accepts post request against that url.@app.route("/change_label")def change_label():    #Return the text you want the label to be    return "New Label"

JAVASCRIPT_FILE

function change_label(){//Create xhttp objectvar xhttp = new XMLHttpRequest();//Listen for the response of your xhttp objectxhttp.onreadystatechange = function() {  if (this.readyState == 4 && this.status == 200) {    //If the request is 200 aka succesfull, set the text of the label to the response text of the xhttp request    document.getElementById("Id of the label").innerHTML =    this.responseText;  }};//Open a post request with the xhttp object. xhttp.open("POST", "http://domain/change_label", true);// Send the post requestxhttp.send();}

HTML FILE

 <html> <head> <title>Video Streaming Demonstration</title> <script src="link_to_javascript"></script> </head> <body> <h1>Video Streaming Demonstration</h1> <img src="{{ url_for('calc') }}"> </body> </html>

Sorry if its hard to understand, i am very bad at explaining things, my brain is just not wired normally