api index
This commit is contained in:
parent
334ef5bb2a
commit
152bd3fe5f
|
@ -186,8 +186,18 @@ function Websrv(tbot, tsql, tcfg, tlib) {
|
|||
else if(filePath.match(/^\.\/api/i)) { // api
|
||||
var url = filePath.split('/');
|
||||
if(url[2] === undefined) { // Mainpage
|
||||
res.writeHead(200, { 'Content-Type': contentType });
|
||||
res.end('kommt noch');
|
||||
var query = "select * from `f0ck`.`items`";
|
||||
sql.query(query, (err, rows, fields) => {
|
||||
var items = [];
|
||||
rows.forEach((e,i,a) => {
|
||||
items.push({
|
||||
'id': e.id,
|
||||
'mime': e.mime
|
||||
});
|
||||
});
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' });
|
||||
res.end(JSON.stringify(items), 'utf-8');
|
||||
});
|
||||
}
|
||||
else if(Number.isInteger(parseInt(url[2]))) { // Item
|
||||
var query = "select * from `f0ck`.`items` where `id` = ? limit 1; " // get item
|
||||
|
|
Loading…
Reference in New Issue
Block a user