Skip to content

Commit 4180b6d

Browse files
authored
feat: adds Tyran's Lesson 21 with Form Functionality and GET/POST request (#689)
1 parent 036dd95 commit 4180b6d

File tree

13 files changed

+1701
-0
lines changed

13 files changed

+1701
-0
lines changed

lesson_21/tyranricejr/index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const express = require('express');
2+
const path = require('path');
3+
const morgan = require('morgan');
4+
var debug = require('debug')('myapp:server');
5+
6+
const app = express();
7+
8+
app.use(morgan('dev'));
9+
app.use(express.static(path.join(__dirname, 'public')));
10+
app.use(express.json());
11+
12+
const PORT = process.env.PORT || 3000;
13+
14+
app.get('/signup' , (req, res) => {
15+
res.sendFile(__dirname + '/public/signup/signup.html');
16+
});
17+
18+
app.get('/signupdone' , (req, res) => {
19+
res.sendFile(__dirname + '/public/signup/signupdone.html');
20+
});
21+
22+
app.post('/signup', (req, res) => {
23+
const { name, email, password } = req.body;
24+
debug(`New signup:\n Name: ${name},\n Email: ${email},\n Password: ${password}`);
25+
26+
res.json({ message: `Thank you for signing up, ${name}!` });
27+
});
28+
29+
app.listen(PORT, () => {
30+
debug(`Server is running on http://localhost:${PORT}`);
31+
}
32+
);

0 commit comments

Comments
 (0)