Skip to content

Commit e86d133

Browse files
A1-4U2T1NN“A1-4U2T1NN”
andauthored
Feat: Added web server and contact form for Lesson 23/24; (#640)
* feat: created chigazograham.json file * fix: deleted lesson_09 content from main; * feat: added CSS for index.html incuding the following sections body, header and header subsets, hero and hero subsets, program and program subsets, and footer; * fix: removed style.css from main branch; * feat: used Express and Morgan to create a web server; imported lesson 22 files; created contact.html file and filled in content with basic contact form; opened a new port in the dev container to support serving traffic from your web server; * feat: added url parser and json parser along; added data display for contact form; * feat: updated css to look fit the code differently website; --------- Co-authored-by: “A1-4U2T1NN” <“[email protected]”>
1 parent 8cb11b3 commit e86d133

File tree

9 files changed

+1199
-0
lines changed

9 files changed

+1199
-0
lines changed

lesson_22/template/style.css

Whitespace-only changes.

lesson_24/chigazograham/index.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const express = require('express');
2+
const morgan = require('morgan');
3+
const path = require('path');
4+
const bodyParser = require('body-parser');
5+
6+
const app = express();
7+
8+
app.use(morgan('dev'));
9+
app.use(express.static(path.join(__dirname, 'public')));
10+
app.use(bodyParser.urlencoded({ extended: true }));
11+
app.use(bodyParser.json());
12+
13+
const PORT = process.env.PORT || 3000;
14+
15+
app.post('/contact', async (req, res) => {
16+
const { name, email, feedback } = req.body;
17+
res.send(`
18+
<h1>Form Submitted</h1>
19+
<p><strong>Name:</strong> ${name}</p>
20+
<p><strong>Email:</strong> ${email}</p>
21+
<p><strong>Feedback:</strong> ${feedback}</p>
22+
<a href="/contact">Go back to the form</a>
23+
`);
24+
});
25+
26+
app.listen(PORT, () => {
27+
console.log(`Server is running on port ${PORT}`);
28+
});

0 commit comments

Comments
 (0)