Express Part2

 //=============Server.js===========

let express=require('express');
let app=express();

app.get('/', function (req, res) {


// res.send('Hello world');
res.sendFile(__dirname+'/index.html')
// res.format({
// 'application/xml':function () {
// res.send({message:'hi I am sabir'})
// }
// })
});


app.get('/LogIn', function (req, res) {
let userName=req.param('username');
let class_=req.param('class');

res.send(`UserName=${userName} Class=${class_}`);
})


app.get('/DownoadCovid', function (req, res) {

res.download('covid.csv','yavatmalCovid.csv');
})






let server = app.listen(3022,function () {
console.log('Server Start');
console.log("Example app listening at http://localhost:3022")
})


//==============index.html=========

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>Computer</h1>
<h2>LapTop</h2>
<table>
<thead>
<tr>
<th>Sr</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>sabir</td>
</tr>
</tbody>
</table>
</body>
</html>


Comments

Popular posts from this blog

App 1st User Define Component

Example 1

Rabiit