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

@ -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());*/
});