1const http = require('http');
2const fs = require('fs');
3
4const hostname = '127.0.0.1';
5const port = 3000;
6
7fs.readFile('./index.html', (err, html) => {
8 if(err){
9 throw err;
10 } else if(html){
11 const server = http.createServer((req, res) => {
12 res.statusCode = 200;
13 res.setHeader('Content-type', 'text/html');
14 res.write(html);
15 res.end();
16 });
17}
18});
19
20
21server.listen(port, hostname, () => {
22 console.log('Server started on port ' + port);
23});
24