1let http = require('http');
2let fs = require('fs');
3
4let handleRequest = (request, response) => {
5 response.writeHead(200, {
6 'Content-Type': 'text/html'
7 });
8 fs.readFile('./index.html', null, function (error, data) {
9 if (error) {
10 response.writeHead(404);
11 respone.write('Whoops! File not found!');
12 } else {
13 response.write(data);
14 }
15 response.end();
16 });
17};
18
19http.createServer(handleRequest).listen(8000);
20