-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
68 lines (58 loc) · 2.04 KB
/
server.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
59
60
61
62
63
64
65
66
67
68
var path = require("path"),
mailer = require("./lib/mailer"),
generateDineroMailUrl = require("./lib/dineromail");
var express = require("express"),
stylus = require("stylus"),
nib = require("nib"),
app = express();
app.configure(function(){
this.locals.pretty = true;
this.set("views", __dirname + "/views");
this.set("view engine", "jade");
this.use(express.bodyParser());
this.use('/css', stylus.middleware({
src: __dirname + "/stylesheets",
dest: __dirname + "/public/css",
compile: function compile(str, filePath) {
return stylus(str)
.set('filename', filePath)
.set('paths', [ __dirname + "/stylesheets" ])
.set('compress', true)
.use(nib())
.import('nib');
}
}));
this.use(express.compress());
this.use(express.static(__dirname + "/public"));
this.use(app.router);
});
app.get("/", function(req, res){
res.render("index", {
photos: [
{file: "/photos/IMG_0951.jpg", description: "Noders!"},
{file: "/photos/IMG_0953.jpg", description: "Matías explicando módulos en node.js con legos"},
{file: "/photos/IMG_0952.jpg", description: "hora de ejercicios!"},
{file: "/photos/IMG_0963.jpg", description: "Damian explicando express.js"},
{file: "/photos/IMG_0960.jpg", description: "José explicando un ejercicio"},
{file: "/photos/IMG_0962.jpg", description: "con hambre no se puede pensar"},
{file: "/photos/IMG_0955.jpg", description: "Matías explicando funcionamiento de require"},
{file: "/photos/IMG_0969.jpg", description: "Damian explicando funcionamiento de socket.io"},
{file: "/photos/IMG_0971.jpg", description: "y más ejercicios"}
]
});
});
app.get("/succeed", function(req, res){
res.render("succeed");
});
app.post("/", function(req, res){
mailer(req.body.email, req.body.category, function(err){
if(err){
res.send(500, err);
}else{
res.redirect(generateDineroMailUrl(req.body));
}
});
});
app.listen(8001, function(){
console.log("listening on http://localhost:8001");
});