-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (24 loc) · 797 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
var express = require('express')
var app = express()
var exphbs = require('express-handlebars')
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'handlebars');
app.set('port', process.env.PORT || 3000)
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.get('/', function (req, res) {
res.render('home');
})
app.get('/results', function (req, res) {
let response = `<div><ul>`
for(let param in req.query) {
response += `<li>${param} : ${req.query[param]}<li>`
}
response += `</ul></div>`
res.send(response)
})
var http = require('http')
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'))
});