My index.html file:
<!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>
My index.js file:
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");
});
I am trying to make a simple Website using NodeJS, Express, HTML and JavaScript but for some reason the background I added in index.html is not showing up when I run my server (localhost:3000). I am using API to get the data. I don't seem to understand the problem. It's showing other elements like button and form but not the background. HTML background image not showing up in my .js file why? Is there any other way to do it? I don't seem to understand the problem. I also tried using <script src in html file.