-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (27 loc) · 901 Bytes
/
Copy pathserver.js
File metadata and controls
32 lines (27 loc) · 901 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
25
26
27
28
29
30
31
32
var http = require('http')
const { read } = require('fs')
var server = http.createServer(function(req, res){
// res.json("Welcome to my Site");
// res.end();
if(req.url == '/'){
res.writeHead(200, {'Content-Type':'text/html'})
res.write('<html><body><h1>THIS IS HOEM PAGE</h1></body></html>')
res.end();
}
if(req.url == '/student'){
res.writeHead(200, {'Content-Type':'text/html'})
res.write('<html><body><h1>THIS IS STUDENT PAGE</h1></body></html>')
res.end();
}
if(req.url == '/teacher'){
res.writeHead(200, {'Content-Type':'text/html'})
// res.write('<html><body><h1>THIS IS TEACHER PAGE</h1></body></html>')
res.write(JSON.stringify({message:"Hello World"}))
res.end();
}
else{
res.end('Invalid Request!')
}
})
server.listen(8080)
console.log("Server Started")