-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
44 lines (31 loc) · 954 Bytes
/
index.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
'use strict';
var fs = require('fs-extra'),
path = require('path'),
utils = require('./lib/frozen/utils');
var config = utils.readJsonSync('./config.json');
global.frozen = {
appRoot: __dirname,
config: config
};
var Frozen = require('./lib/frozen');
Frozen.init();
// run build
exports.build = function () {
Frozen.build();
};
// create http server
exports.server = function (port) {
var frozen = global.frozen,
Static = require('node-static');
var fileServer = new Static.Server(path.relative(__dirname, frozen.pagesDir));
port = port || 8000;
require('http').createServer(function (request, response) {
request.addListener('end', function () {
fileServer.serve(request, response)
.addListener('error', function (err) {
console.error("Error serving " + request.url + " - " + err.message);
});
}).resume();
}).listen(port);
console.log('Server running at http://127.0.0.1:' + port);
};