Skip to content

Commit 7e0fe27

Browse files
authored
feat: adds node web server for hosting html web app as hw24 by Yemi (#578)
* feat: adds node web server creation for hosting html web app as hw24 by Yemi * feat: updated 2 assets
1 parent ed5bdf7 commit 7e0fe27

File tree

8 files changed

+1515
-0
lines changed

8 files changed

+1515
-0
lines changed

lesson_24/oyeyemijimoh/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const express = require('express');
2+
const morgan = require('morgan');
3+
const path = require('path');
4+
const bodyParser = require('body-parser');
5+
const app = express();
6+
app.use(bodyParser.urlencoded({extended:true}))
7+
8+
app.use(morgan('dev'));
9+
app.use(express.static(path.join(__dirname,'public')));
10+
const PORT =process.env.PORT || 3005;
11+
12+
app.listen(PORT, ()=>{
13+
console.log(`Server is running on port ${PORT}`);
14+
});
15+
16+
17+
app.post('/confirmation.html',(req,res)=>{
18+
const q = req.body;
19+
const firstname = q.firstname;
20+
const lastname = q.lastname;
21+
const email = q.email;
22+
console.log(req.body);
23+
res.status(200).send(
24+
`<div> Thank you for completing the contact us form
25+
<p>First Name : ${firstname} </p>
26+
<p> Last Name : ${lastname} </p>
27+
<p> Email Address : ${email} </p>
28+
<p> <a href="index.html">Home</a></p>
29+
</div>`);
30+
});

0 commit comments

Comments
 (0)