forked from sbstjn/timesheet.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serve.js
50 lines (40 loc) · 1.44 KB
/
serve.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
var express = require('express');
var sass = require('node-sass');
var fs = require('fs');
var app = express();
var engines = require('consolidate');
app.engine('haml', engines.haml);
app.set('views', __dirname + '/source');
app.get('/script/lib.js', function(req, res) {
res.end(fs.readFileSync(__dirname + '/source/javascripts/lib.js'));
});
app.get('/script/main.js', function(req, res) {
res.end(fs.readFileSync(__dirname + '/source/javascripts/main.js'));
});
app.get('/script/timesheet.min.js', function(req, res) {
res.end(fs.readFileSync(__dirname + '/dist/timesheet.min.js'));
});
app.get('/styles/timesheet.css', function(req, res) {
res.end(fs.readFileSync(__dirname + '/dist/timesheet.min.css'));
});
app.get('/styles/timesheet-white.css', function(req, res) {
res.end(fs.readFileSync(__dirname + '/dist/timesheet-white.min.css'));
});
app.get('/styles/style.css', function(req, res) {
sass.render({
file: __dirname + '/source/stylesheets/style.sass',
outputStyle: req.query.style || ""
}, function(err, result) {
res.end(result.css.toString());
});
});
app.get('/', function (req, res) {
res.render('index.haml', {
code: fs.readFileSync(__dirname + '/source/snippets/example-date.js') + ''
});
});
var server = app.listen(process.env.PORT || 3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});