I am trying to link styles.css file to hello.html page to show up in the localhost using nodejs. But the output is only formatted in html and css styling isn't displayed.
Here is my code!
project.js
var http = require('http');
var fs = require('fs');
http.createServer(function (req,res){
fs.readFile('hello.html',function(err,data){
res.writeHead(200,{'Content-Type': 'text/html'});
res.write(data);
res.end();
});
}).listen(8080);
hello.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="heading">
<h1>FILE UPLOADING!</h1>
</div>
<form method= "POST" enctype="multipart/form-data" action="fileupload">
<input type="file" name="filetoupload">
<input type="submit" id='bt' value="Submit">
</form>
</body>
</html>
style.css
#heading{
color:green;
font-family: sans-serif,serif;
}
#bt{
background-color: #4CAF50;
color: #ffffff;
border-color: #4CAF50;
}