forked from allen-cell-animated/vole-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
22 lines (16 loc) · 731 Bytes
/
server.js
File metadata and controls
22 lines (16 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const express = require('express');
const app = express();
const morgan = require('morgan');
const cliArgs = require('command-line-args');
app.use(morgan('combined'));
const options = cliArgs([
{ name: 'dir', type: String, alias: 'd', defaultOption: true, defaultValue: __dirname, description: 'Directory to serve from' },
{ name: 'port', type: Number, alias: 'p', defaultValue: 9020, description: 'Port to use' }
]);
const env = process.env.DEPLOYMENT_ENV || 'dev';
console.log('Serving ' + options.dir + ' on port ' + options.port + ' in ' + env);
const router = new express.Router();
app.use('/imageviewer', router);
// send static files back
app.use(express.static(options.dir));
app.listen(options.port, '0.0.0.0');