forked from processing-js/processing-js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
executable file
·41 lines (34 loc) · 1.37 KB
/
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
33
34
35
36
37
38
39
40
41
var http = require("http"),
express = require("express"),
nunjucks = require("nunjucks"),
app = express(),
nunjucksEnv = new nunjucks.Environment(new nunjucks.FileSystemLoader('views'));
nunjucksEnv.express(app);
app.use(express.static('test'));
app.use(express.static('test/tools'));
var js = function(_, res, next) {
res.header('Content-Type', 'application/javascript');
next();
};
app.get("/", function(req, res) { res.render("test.html"); });
app.get("/processing.js", js, function(req, res) { res.render("processing.js"); });
app.get("/processing.min.js", js, function(req, res) { res.render("processing.min.js"); });
// parameters for the termination route
app.param('failed', function(req, res, next, failed) {
app.locals.failed = parseInt(failed, 10);
next();
});
app.param('knownfailed', function(req, res, next, knownfailed) {
app.locals.knownfailed = parseInt(knownfailed, 10);
next();
});
app.param('passed', function(req, res, next, passed) {
app.locals.passed = parseInt(passed, 10);
next();
});
// termination route
app.get("/stopserver/:failed/:knownfailed/:passed", function(req, res) {
console.log(app.locals.failed + "." + app.locals.knownfailed + "." + app.locals.passed);
process.exit(0);
});
app.listen(3000, function() { console.log('Express server listening on port 3000'); });