-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.js
More file actions
32 lines (24 loc) · 700 Bytes
/
3.js
File metadata and controls
32 lines (24 loc) · 700 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
/*
Q.3_Create a Basic Server with Different Routes using Express
`/`→ send response as {msg:`I am homepage`}
`/about`→ send response as {msg:`I am about page`}
`/contact`→ send response as {emai::`suppor#@pwskills.com`}
*/
const express = require('express')
const app = express()
const port = 5000
app.get('/',(req,res)=>{
res.json({Msg:'I am Homepage'})
})
app.get('/about',(req,res)=>{
res.json({Msg:'I am about page'})
})
app.get('/contact',(req,res)=>{
res.json({email:`support@pwskills`})
})
app.get('*', (req, res) => {
res.status(404).json({ error: 'Page not found' });
});
app.listen(port,()=>{
console.log(`Server is running at http://localhost:${port}`)
})