forked from WebDevBootcamp/markdown-presenter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
32 lines (26 loc) · 739 Bytes
/
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
var express = require('express');
var program = require('commander');
var path = require('path')
program
.version('0.0.1')
.option('-m, --mount [path]', 'Mount resource')
.parse(process.argv);
var app = express();
app.use('/', express.static(__dirname));
// mount additional path if needed
if(program.mount) {
var mount = program.mount;
var fragment;
var pos = mount.lastIndexOf('/');
if(pos > 0)
fragment = mount.substring(pos);
else
fragment = '/' + mount;
console.log('mounting ' + mount + ' at ' + fragment);
if(mount[0] !== '/') {
mount = path.join(__dirname, mount);
}
app.use(fragment, express.static(mount));
}
app.listen(3000);
console.log('server listening on http://localhost:3000/');