-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery-parems.js
51 lines (39 loc) · 1.11 KB
/
query-parems.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const express = require('express');
const app = express();
const port = 8000;
app.get( '/' , (req , res) => {
res.send(`
<h1>Welcome , this is home page</h1>
<input type = "text" placeholder = "user name" value= "${req.query.name}" />
<button> Click Me </button>
<a href = '/about'> Go To About </a>
<h3>Accesing quary parems passed from the browser's URL as:- http://localhost:8000/?name=xyz </h3> ${req.query.name}
`);
console.log(req.query.name)
});
app.get('/about' , (req , res) => {
res.end(`<h1>Welcome , this is about page</h1>
const data = [
{
name:"vivek",
2 : "two"
} ,
{
"name":"vivek",
"addr" : "xyz"
}
]
<a href = '/' > Go To Home </a>
`)
console.log(req.body)
});
app.get('/help' , (req , res) => {
res.send('<h1>Welcome this is help page</h1>');
})
app.listen(port , (err) => {
if(err){
console.log(`Error while connecting to server ${err} on PORT ${port}`);
return;
}
console.log('Server running on the port' , port);
});