forked from voloko/learn_js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode.js
31 lines (24 loc) · 752 Bytes
/
node.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
var express = require('express'),
connect = require('connect'),
path = require('path'),
sr = require('ukijs/tools/static_require'),
fs = require('fs');
var HOST = '0.0.0.0',
PORT = 8001;
app = express.createServer();
app.configure(function() {
app.use(connect.bodyParser());
});
app.get('/', sr.getAppHandler('Learn js', 'app.js'));
app.get('/vendor/*', function(req, res){
res.sendfile(req.url.substring(1));
});
app.get('/*.js', sr.getHandler({
searchPaths: [fs.realpathSync(__dirname)].concat(require.paths),
serverRoot: __dirname
}));
app.get('/*', function(req, res) {
res.sendfile(req.param(0));
});
require('util').puts("Server at http://" + HOST + ":" + PORT + "/");
app.listen(PORT, HOST);