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

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

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 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