-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathserver.js
More file actions
18 lines (15 loc) · 519 Bytes
/
server.js
File metadata and controls
18 lines (15 loc) · 519 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const http = require('http');
const fs = require('fs');
const homeFile = fs.readFileSync('sampleHome.html');
const port = 3000;
const hostname = '127.0.0.1';
const server = http.createServer((req, res) => {
// res.statusCode = 200;
// res.setHeader('Content-text','text/html');
res.writeHead(200, {'Content-text':'text/html'});
res.end(homeFile);
})
server.listen(port, hostname, () =>{
// server.listen(3000, '127.0.0.1',()=>{
console.log(`Started the server on http://${hostname}:${port}`);
})