-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (26 loc) · 960 Bytes
/
app.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
const express=require("express");
const fs=require("fs");
const appl=express();
const path=require("path");
const port=80;
appl.use(express.urlencoded());
appl.use('/static',express.static('stat'));
appl.set('view engine','pug');
appl.set('views',path.join(__dirname,'views'));
appl.get('/',(req,res)=>{
res.status(200).render('index.pug');
})
appl.post('/',(req,res)=>{
name=req.body.name;
surname=req.body.surname;
number=req.body.number;
email=req.body.email;
address=req.body.address;
let outputSTR=`The name of the client is ${name} ${surname}, contact number is ${number}, Email ID is ${email} and address is ${address} . \n\n`;
fs.appendFileSync('output.txt',outputSTR);
const data={'message':'Your Form has been submitted successfully'};
res.status(200).render('index.pug');
})
appl.listen(port,()=>{
console.log(`the application started successfully on port ${port}`);
})