stuff lol

This commit is contained in:
Flummi
2019-04-25 19:25:38 +00:00
parent fb633ba64f
commit 48d631f536
12 changed files with 245 additions and 3 deletions

View File

@ -38,7 +38,7 @@ router.get(/^\/api\/p(\/[0-9]+|\/)?(\/[0-9]+)?\/?$/, async (req, res) => {
"items": [],
"last": id
};
rows.forEach((e,i,a) => {
rows.forEach(e => {
items.items.push({
"id": e.id,
"mime": e.mime

View File

@ -0,0 +1,3 @@
export const queries = {
items: "select id, mime from f0ck.items order by id desc limit 72"
};

View File

@ -1,5 +1,22 @@
import router from "../router";
import fs from "fs";
import sql from "../sql";
import handlebars from "handlebars";
router.get(/^\/$/, (req, res) => {
res.end("index lol");
import { queries } from "./inc/index";
const template = fs.readFileSync("./views/index.html.tpl", "utf-8");
router.get(/^\/$/, async (req, res) => {
const db = await sql;
res.writeHead(200, { 'Content-Type': 'text/html' });
db.query(queries.items)
.then(items => {
const tpl = handlebars.compile(template);
res.end(tpl({ items: items }));
}).catch(err => res.end(JSON.stringify( err ), 'utf-8'));
/*const tpl = handlebars.compile(template);
res.end(tpl());*/
});