-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpGetPostContact.js
More file actions
47 lines (33 loc) · 991 Bytes
/
httpGetPostContact.js
File metadata and controls
47 lines (33 loc) · 991 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var urlencodedParser = bodyParser.urlencoded({extended: false});
app.set('view engine', 'ejs');
app.get('/', function (req, res) {
res.send('This is home page');
});
app.get('/home', function (req, res) {
res.send('This is also home page');
});
app.get('/profile/:id', function (req, res) {
var data = {
age: 25,
job: 'Ninja'
};
res.render('profile', {person: req.params.id, data: data});
});
app.post('/contact', urlencodedParser, function (req, res) {
console.log(req.body);
//res.render('echoejs', {data: req.body});
res.json(req.body);
});
app.get('/contact', function (req, res) {
console.log(req.query);
res.render('contact', {qs: req.query});
});
app.get('/contact/curlpost', function (req, res) {
console.log(req.query);
res.render('contact', {qs: req.query});
});
app.disable('x-powered-by');
app.listen(80);