-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml and json.js
48 lines (37 loc) · 950 Bytes
/
html and json.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
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" />
<button> Click Me </button>
<a href = '/about'> Go To About </a>
`);
});
app.post('/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);
});