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

152
Visualizações
i have written it as res.send(). so gettingTO a page with noCSS just the data written i wnat to change the CSSproperties of that page how to do that

I have written this code for weather app how to change the background and CSS properties of the page the data is getting posted

app.post("/", (req, res) => {

    const query = req.body.cityName;
    const apiKey = "48a9ebfd3c72f0c53af5c483631e82ad";
    const unit = "metric";
    const url = "https://api.openweathermap.org/data/2.5/weather?q=" + query + "&appid=" + apiKey + "&units=" + unit;

    https.get(url, (response) => {
        console.log(response.statusCode);

        response.on("data", (d) => {
            const weatherData = JSON.parse(d);
            const weatherDescription = weatherData.weather[0].description;
            const temp = weatherData.main.temp;
            const windSpeed = weatherData.wind.speed;
            const pressure = weatherData.main.pressure;
            const icon = weatherData.weather[0].icon;
            const imageUrl = "http://openweathermap.org/img/wn/" + icon + "@2x.png";

            res.write("<p>Temperature  " + query + " is " + temp + "  degrees celcius.</p>");
            res.write("<p> Weather description - " + weatherDescription + "</p>");
            res.write("<p>Wind speed " + windSpeed + " Km/hr </h4>");
            res.write("<p>Pressure is  " + pressure + " mbar </p>");
            res.write("<img src=" + imageUrl + "> ");
            res.send();
        });
    });
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I understand from your comments now :)
If you want to change the css, you need to add a style property to your html tags.

For example:

res.write("<p style='background-color:red;'>Temperature  " + query + " is " + temp + "  degrees celcius.</p>");

You can find more information here: https://www.w3schools.com/html/html_css.asp#:~:text=try%20it%20yourself.-,Inline%20CSS,-An%20inline%20CSS

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