Express JS - Render HTML and JSON
const express=require('express');
const app=express();
app.get('', (req, resp)=>{
// console.log("Data sent by Browser =>", req.query.name)
// resp.send('Hello, this is a home page');
resp.send(`
<h1>Jai Sri Krishna</h1>
<a href="/about">Go to About Page</a>
`);
});
app.get('/about', (req, resp)=>{
// resp.send('Hello, this is a about page');
resp.send(`
[
{
name:'krishan',
email:'krishan@gmail.com'
},
{
name:'Radhe',
email:'radhe@gmail.com'
}
]
<a href="/">Go to Home Page</a>
`);
});
app.listen(5000);
Comments
Post a Comment