nedap server: all errors are 503 Bad Gateway, Internetkurort

This commit is contained in:
Astro 2011-12-14 17:05:10 +01:00
parent a1b0fbb25e
commit 5602b3ae94
2 changed files with 10 additions and 12 deletions

View File

@ -61,6 +61,12 @@ function updateBackend() {
}
}
function errorResponse(res) {
res.writeHead(503, { 'Content-type': MIME_HTML });
res.write("<img src=\"/503.png\">");
res.end();
}
function nedap(app) {
app.get('/', function(req, res) {
if (mode === 'nedap' &&
@ -125,16 +131,10 @@ function nedap(app) {
'Location': '/thanks' });
res.end();
} else {
res.writeHead(400, { 'Content-type': MIME_HTML,
'Location': '/' });
res.write(html("<p>Face validation error.</p>"));
res.end();
errorResponse(res);
}
} else {
res.writeHead(400, { 'Content-type': MIME_HTML,
'Location': '/' });
res.write(html("<p>Huh?</p>"));
res.end();
errorResponse(res);
}
});
@ -147,8 +147,7 @@ function nedap(app) {
app.post('/i', function(req, res) {
if (req.files.gif) {
if (!Token.validate(req.body.token)) {
res.writeHead(200, { 'Content-type': MIME_HTML });
res.end("Cheater!");
errorResponse(res);
return;
}
/* pass to frontend */
@ -171,8 +170,7 @@ function nedap(app) {
res.end();
} else {
console.error(err.stack || err);
res.writeHead(500, { 'Content-type': 'text/plain' });
res.end("Oops");
errorResponse(res);
}
});

BIN
nedap/static/503.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB