-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
70 lines (58 loc) · 2.08 KB
/
app.js
File metadata and controls
70 lines (58 loc) · 2.08 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* A simple ExpressJS server app
*/
'use strict';
var express = require('express');
var http = require('http');
var path = require('path');
var app = express();
var server = http.createServer(app);
var logJson = {logs: []};
app.get('/', function(req, res) {
// Toggle between serving public/index.html
// and sending a text 'Ola Mundo!' to see
// nodemon restarting the server upon edit
res.sendfile('index.html');
// res.send('Ola Mundo!');
});
app.use('/app', express.static(path.resolve(__dirname, 'app')));
app.use('/build', express.static(path.resolve(__dirname, 'build')));
app.use('/build/command-input', express.static(path.resolve(__dirname, 'build/command-input')));
app.use('/build/command', express.static(path.resolve(__dirname, 'build/command')));
app.use('/build/log', express.static(path.resolve(__dirname, 'build/log')));
app.use('/build/service', express.static(path.resolve(__dirname, 'build/service')));
app.use('/build/settings', express.static(path.resolve(__dirname, 'build/settings')));
app.use('/css', express.static(path.resolve(__dirname, 'css')));
app.use('/node_modules', express.static(path.resolve(__dirname, 'node_modules')));
app.use('/getKnownCommands', express.static("data/known-cmds.json"));
app.get('/run', function(req, res) {
var command = req.param("command");
logJson.logs.push({
logLevel: "INFO",
message: "Processing command:'" + command + "' (0 left)",
exception: null,
time: 1458138685531
});
logJson.logs.push({
"logLevel": "INFO",
"message": "Syntax matched (executed): " + command,
"exception": null,
"time": 1458138685532
});
logJson.logs.push({
"logLevel": "INFO",
"message": "Command processed (0 ms)",
"exception": null,
"time": 1458138685535
});
res.sendStatus(200);
});
app.get('/getLogs', function(req, res) {
res.json(logJson);
logJson.logs.splice(0, logJson.logs.length);
});
app.use(express.static('public'));
server.listen(3000);
server.on('listening', function() {
console.log('Express server started on port %s at %s', server.address().port, server.address().address);
});