Skip to content

Commit

Permalink
Rendring Html And JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
codingXpert committed Jun 29, 2022
1 parent e772bc1 commit f14f467
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion express.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ app.get('/help' , (req , res) => {

app.listen(8000 , () => {
console.log('Server running on the port 8000')
});
});
48 changes: 48 additions & 0 deletions html and json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
});

0 comments on commit f14f467

Please sign in to comment.