Hello everyone, I hope you're all well. I have a question regarding creating a navigation bar and serving it on my server. Every time I try to do so, I am getting a 404 not found error. However, I have placed my logo file in the same directory as my HTML code, which looks like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Discord Chat</title>
<link href="https://fonts.googleapis.com/css2?family=Karla&display=swap" rel="stylesheet">
<link rel="icon" href="logo.png">
<style>
* {
margin: 0px;
padding: 0px;
font-family: 'Karla', sans-serif;
}
#logo {
width: 50px;
height: 50px;
border-radius: 30px;
}
.navbar ul{
position: sticky;
}
.navbar ul li a{
text-decoration: none;
text-transform: none;
color: lightseagreen;
}
.navbar ul li{
list-style: none;
display: inline;
position: relative;
top: -30px;
left: 71px;
padding: 20px;
}
.navbar{
background-color: black;
opacity: 0.6;
}
.navbar ul li:hover {
cursor: pointer;
border-radius: 50px;
animation-name: navanim;
animation-duration: 5s;
animation-iteration-count: 1;
font-size: 20px;
}
@keyframes navanim{
from{
background-color: white;
color: black;
}
to{
background-color: black;
color: white;
}
}
</style>
</head>
<body>
<nav class="navbar">
<img src="logo.png" alt="Discord Chat" id="logo">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
</ul>
</nav>
</body>
</html>
And here is my server-side code:
var app = require('express')();
var http = require('http').Server(app);
const port = 8000;
app.get('/', (req, res) => {
res.sendfile('index.html');
});
http.listen(port, function(){
console.log(`Server is listening on https://127.0.0.1:${port}/ `);
});
Any ideas on how I can successfully display my logo on my website?