🌶🍲 Checkpoint
./views/room.handlebars:530995/365 ./server.js:530995/486 ./views/join.handlebars:530995/26 ./package.json:530995/1360
This commit is contained in:
parent
c2acb83882
commit
0c20db100b
@ -11,7 +11,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.17.1",
|
||||
"express-handlebars": "^4.0.3"
|
||||
"express-handlebars": "^4.0.3",
|
||||
"body-parser": "^1.19.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "12.x"
|
||||
|
14
server.js
14
server.js
@ -1,7 +1,13 @@
|
||||
const express = require("express");
|
||||
var exphbs = require('express-handlebars');
|
||||
const exphbs = require('express-handlebars');
|
||||
const bodyParser = require('body-parser')
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({
|
||||
extended: true
|
||||
}));
|
||||
app.engine('handlebars', exphbs());
|
||||
app.set('view engine', 'handlebars');
|
||||
|
||||
@ -12,7 +18,11 @@ app.get("/:roomId/join", (request, response) => {
|
||||
});
|
||||
|
||||
app.post("/:roomId/join", (request, response) => {
|
||||
response.render('room', {layout: false, room: request.params.roomId});
|
||||
response.render('room', {
|
||||
layout: false,
|
||||
room: request.params.roomId,
|
||||
name: request.body.name
|
||||
});
|
||||
});
|
||||
|
||||
const listener = app.listen(process.env.PORT, () => {
|
||||
|
@ -1,4 +1,5 @@
|
||||
dependencies:
|
||||
body-parser: 1.19.0
|
||||
express: 4.17.1
|
||||
express-handlebars: 4.0.3
|
||||
packages:
|
||||
@ -562,5 +563,6 @@ registry: 'https://registry.npmjs.org/'
|
||||
shrinkwrapMinorVersion: 9
|
||||
shrinkwrapVersion: 3
|
||||
specifiers:
|
||||
body-parser: ^1.19.0
|
||||
express: ^4.17.1
|
||||
express-handlebars: ^4.0.3
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
<p>Tell me your (team) name:</p>
|
||||
|
||||
<form>
|
||||
<form method="POST">
|
||||
<label>
|
||||
Name
|
||||
<input name="name" type="text" maxlength="100" required>
|
||||
|
@ -12,21 +12,15 @@
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Join {{room}}</h1>
|
||||
<h1>{{room}}</h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<h2>Oh hi,</h2>
|
||||
|
||||
<p>Tell me your (team) name:</p>
|
||||
|
||||
<form>
|
||||
<label>
|
||||
Name
|
||||
<input name="name" type="text" maxlength="100" required>
|
||||
</label>
|
||||
<button type="submit" id="submit-name">Submit</button>
|
||||
</form>
|
||||
<h2>Oh hi, {{name}}</h2>
|
||||
|
||||
<button id="buzzer">
|
||||
BUZZ
|
||||
</button>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user