let http = require("http");
let fs = require("fs");
http.createServer(function(request, response) {
console.log(request.url);
fs.readFile('.' + request.url, (err, data) => {
if (err){
response.writeHead(404, {"Content-type" : "text/html"});
response.write('File not found');
response.end();
console.log(err);
} else {
response.writeHead(200, {"Content-type" : "text/html"});
response.write(data);
response.end();
}
});
}).listen(8000);
app.use(express.static('public'));
var express = require('express');
var app = express();
app.use(express.static('public'));
app.listen(8000, function() {
console.log("Server started at " + 8000 + " port");
});