Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

373
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda