-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
24 lines (20 loc) · 774 Bytes
/
Copy pathapp.js
File metadata and controls
24 lines (20 loc) · 774 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
import http from 'http';
const PORT = 5000;
const app = http.createServer((request,response)=>{
response.writeHead(200,{'Content-Type':'text/html'});
if(request.url == '/'){
return response.end('<h1>Welcome to my home page</h1>');
}else if (request.url == '/about'){
return response.end('<h1>About us</h1>');
}else if(request.url == '/contact'){
return response.end('<h1>Contact us</h1>');
}else if(request.method == 'POST'){
return response.end('<h1>You have sent a POST request</h1>');
}else{
return response.end('<h1>404 Not Found</h1>');
}
response.end("<h1>HomePage</h1>");
});
app.listen(PORT,()=>{
console.log(`Server running on port ${PORT}`);
})