adds random route

This commit is contained in:
jkhsjdhjs 2016-08-16 20:17:12 +02:00
parent 2c4a25f257
commit 86b826788e

View File

@ -274,6 +274,13 @@ http.createServer((req, res) => {
res.end(tpl(data), 'utf-8'); res.end(tpl(data), 'utf-8');
}); });
} }
else if(filePath == "./random") {
sql.query("select `id` from `f0ck`.`items` order by rand() limit 1", null, (err, rows, fields) => {
res.writeHead(301, {
Location: req.headers.host + '/' + rows[0][0].id
});
});
}
else if(filePath == "./how") { else if(filePath == "./how") {
var tpl = swig.compile(templates.how); var tpl = swig.compile(templates.how);
res.writeHead(200, { 'Content-Type': 'text/html' }); res.writeHead(200, { 'Content-Type': 'text/html' });