Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

371
Views
How to fetch the data from flask webpage and change the button color on another webpage?

I have this application which displays temperature values on a python flask web page. I am working on a webpage which will open this flask web page on a click of button. So the question is, how these two pages can communicate. I would like to access the status or any errors from flask webpage and change the color of the button accordingly. Can someone please help me with any examples or code snippets? thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Do you have access to the flask application? I would suggest to build an endpoint, that provides the needed data as json. Your second webpage can then access the data via XMLHttpRequest (JavaScript) and process the data and manipulate your DOM.

Endpoint in flask application:

from flask import jsonify

@app.route('/api/data')
def send_data():
    data = {'status': 1}
    return jsonify(data)

Javascript request:

function getStatus()
{
    var url = "yourdomain.com/api/data";
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", url, false );
    xmlHttp.send( null );
    return xmlHttp.responseText;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!