-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f14f467
commit e5e9ac2
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
}); |