-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
35 lines (26 loc) · 1.12 KB
/
app.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
// R2C2 Remote Control WebInterface
// $ node server.js 8080 /dev/ttyACM0
// $ npm start (for testing, will use port 8080 and /dev/null interface)
var flatiron = require('flatiron'),
//director = require('director'),
path = require('path'),
ecstatic = require('ecstatic'),
app = flatiron.app,
ecore = require('./lib/enginecore.js');
// flatiron configurations
app.config.file({ file: path.join(__dirname, 'config', 'config.json') });
// flatiron plugins
app.use(flatiron.plugins.http);
// flatiron - ecstatic (server resources from directory - html, css, js, images)
app.http.before = [
ecstatic(__dirname + '/public')
];
// using flatiron
//app.router.configure({"strict":false, "notfound":norouterfound, "before":onbefore });
// flatiron router - API for GCODE commands - call parseGCodeCmd from enginecore.js
app.router.get('/gcode/:cmd', ecore.parseGCodeCmd);
app.router.get('/gcodestream/:filename', ecore.streamGCodeFile);
app.router.get(/stldownload\/((\w|.)*)/, ecore.stlDownload);
// launch app on tcpoprt
app.start(ecore.getTcpPort);
console.log('WebInterface Server running on port '+ecore.getTcpPort);