Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

374
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda