-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
32 lines (29 loc) · 814 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var http=require("http");
var myfun=require("./myfun");
var server=http.createServer(function(req,res){
if(req.url=="/"){
res.writeHead(200,{'content-type':'text/json'});
res.write("{'CourseName':'NodeJS','Code':'INT222'}" + myfun());
res.end();
}
if(req.url=="/student"){
res.write("This is STUDENT Web page");
res.end();
}
if(req.url=="/employee"){
res.write("This is Employee Web page");
res.end();
}
});
server.listen(5000);
console.log("Server Connected at Port 5000");
var fs=require("fs");
// Example for a blocking code
/*var data=fs.readFileSync("demo.txt");
console.log(data.toString());*/
// Example for a Non blocking code
fs.readFile("demo.txt",(err,data)=>{
if(err) throw err;
console.log(data.toString());
});
console.log("Program Ended");