-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver-route.js
More file actions
24 lines (21 loc) · 810 Bytes
/
Copy pathserver-route.js
File metadata and controls
24 lines (21 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var http = require('http');
var fs = require('fs');
http.createServer(function(req, res){
if(req.url === "/"){
res.writeHead(200, {'Content-Type':'text/html'});
var myStream = fs.createReadStream(__dirname+"/"+'index.html','utf8');
myStream.pipe(res);
} else if(req.url === "/home"){
res.writeHead(200, {'Content-Type':'text/html'});
var myStream = fs.createReadStream(__dirname+"/"+'home.html','utf8');
myStream.pipe(res);
} else if(req.url === "/about"){
res.writeHead(200, {'Content-Type':'text/html'});
var myStream = fs.createReadStream(__dirname+"/"+'about.html','utf8');
myStream.pipe(res);
} else {
res.writeHead(200, {'Content-Type':'text/html'});
var myStream = fs.createReadStream(__dirname+"/"+'error.html','utf8');
myStream.pipe(res);
}
}).listen(3000,'127.0.0.1');