-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
50 lines (40 loc) · 1.25 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
/**
* Module dependencies.
*/
var express = require('express');
var stylus = require('stylus');
// Auto-compile sass to css with "compiler"
// and then serve with connect's staticProvider
var app = express.createServer();
// add the stylus middleware, which re-compiles when
// a stylesheet has changed, compiling FROM src,
// TO dest. dest is optional, defaulting to src
app.use(stylus.middleware({
src: __dirname + '/views'
, dest: __dirname + '/public'
, compile: compile
}));
// Path to our public directory
var pub = __dirname + '/public';
// Optional since express defaults to CWD/views
app.set('views', __dirname + '/views');
app.use(app.router);
app.use(express.static(pub));
app.use(express.errorHandler({ dump: true, stack: true }));
function compile(str, path, fn) {
stylus(str)
.set('filename', path)
.set('compress', true)
.render(fn);
};
// Set our default template engine to "jade"
// which prevents the need for extensions
// (although you can still mix and match)
app.set('view engine', 'jade');
var imageElements = require('./imageElements.js');
var set1 = imageElements.set1();
app.get('/', function(req, res){
res.render('rotator', {elements: set1});
});
app.listen(3000);
console.log('Express app started on port 3000');