Mi archivo index.html :
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Weather</title> </head> <body style = "background: url(weather.jpeg); background-size: cover";> <h1>My weather application</h1> <form action="/" method="post"> <input type="text" name="cityy" placeholder="Enter city name"> <button type="submit" name="submit">Enter</button> </form> </body> </html> Mi archivo index.js :
const express = require("express"); const https = require("https"); const bodyParser = require("body-parser") const app = express(); app.use(bodyParser.urlencoded({extended: true})); app.get("/", function (req, res) { res.sendFile(__dirname + "/index.html"); }); Estoy tratando de hacer un sitio web simple usando NodeJS, Express, HTML y JavaScript, pero por alguna razón, el fondo que agregué en index.html no aparece cuando ejecuto mi servidor (localhost: 3000). Estoy usando API para obtener los datos. Parece que no entiendo el problema. Muestra otros elementos como el botón y el formulario, pero no el fondo. La imagen de fondo HTML no aparece en mi archivo .js , ¿por qué? ¿Hay alguna otra forma de hacerlo? Parece que no entiendo el problema. También intenté usar <script src en el archivo html.