-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path23-Server.js
More file actions
25 lines (23 loc) · 767 Bytes
/
23-Server.js
File metadata and controls
25 lines (23 loc) · 767 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
const http = require('http')
const {readFileSync}= require('fs')
const HomePage= readFileSync('./NavBar-task/navbar-app/Index.html')
const server = http.createServer((req,res)=>{
//console.log('User hit the server') developer.mozilla.org
const url=req.url
if(url==='/'){
res.writeHead(200,{'content-type':'text/html'})
res.write(HomePage)
res.end()
}
else if(url==='/about'){
res.writeHead(200,{'content-type':'text/html'})
res.write('<h1>About Page</h>')
res.end()
}
else {
res.writeHead({'content-type':'text/html'})
res.write('<h1>Page Not Found</h>')
res.end()
}
})
server.listen(5000)