-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
58 lines (29 loc) · 990 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var express = require('express');
var http = require('http');
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.use(express.bodyParser());
app.get('/', function(request, response) {
response.send('¡Hola, Express!');
});
// app.get('/users/:userName', function(request, response) {
// var name = request.params.userName;
// response.send('¡Hola, ' + name + '!');
// });
app.post('/users', function(request, response) {
var username = request.body.username;
response.send('¡Hola, ' + username + '!');
});
app.get(/\/personal\/(\d*)\/?(edit)?/, function (request, response) {
var message = 'el perfil del empleado #' + request.params[0];
if (request.params[1] === 'edit') {
message = 'Editando ' + message;
} else {
message = 'Viendo ' + message;
}
response.send(message);
});
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});