|
|
@ -52,19 +52,24 @@ const configure = async (fastify, opts) => { |
|
|
|
app.register(Formbody); |
|
|
|
app.register(Formbody); |
|
|
|
|
|
|
|
|
|
|
|
app.get("/*", (req, rep) => { |
|
|
|
app.get("/*", (req, rep) => { |
|
|
|
const target = path.resolve(path.join("pages", req.url)); |
|
|
|
try { |
|
|
|
const index = path.resolve(path.join("pages", req.url, "index.html")); |
|
|
|
const target = path.resolve(path.join("pages", req.url)); |
|
|
|
|
|
|
|
const index = path.resolve(path.join("pages", req.url, "index.html")); |
|
|
|
if(fs.existsSync(index)) { |
|
|
|
|
|
|
|
const result = nunjucks.render(index); |
|
|
|
if(fs.existsSync(index) && !fs.statSync(index).isDirectory()) { |
|
|
|
rep.code(200).type("text/html").send(result); |
|
|
|
const result = nunjucks.render(index); |
|
|
|
} else if(fs.existsSync(target)) { |
|
|
|
rep.code(200).type("text/html").send(result); |
|
|
|
const fname = req.url.slice(1); |
|
|
|
} else if(fs.existsSync(target)) { |
|
|
|
const result = nunjucks.render(fname); |
|
|
|
const fname = req.url.slice(1); |
|
|
|
rep.code(200).type("text/html").send(result); |
|
|
|
const result = nunjucks.render(fname); |
|
|
|
} else { |
|
|
|
rep.code(200).type("text/html").send(result); |
|
|
|
console.error("404 NOT FOUND", target, "NO INDEX", index); |
|
|
|
} else { |
|
|
|
rep.code(404).type("text/html").send("Not Found"); |
|
|
|
console.error("404 NOT FOUND", target, "NO INDEX", index); |
|
|
|
|
|
|
|
rep.code(404).type("text/html").send("Not Found"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch(error) { |
|
|
|
|
|
|
|
console.error(error); |
|
|
|
|
|
|
|
rep.code(500).type("text/html").send("Internal Server Error"); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|