Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
QuiteAFancyEmerald committed Jul 8, 2024
2 parents c16b665 + 9b1a9ae commit 8617872
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ app.use(
// Query strings like /?j are converted into paths like /views/hidden.html
// back here. Which query string converts to what is defined in routes.mjs.
router.get("/", async (req, res) =>
res.send(
paintSource(
loadTemplates(
tryReadFile(
// Return the index page if the query is not found, as there is no
// undefined page in routes.mjs. Also sets it as the default page.
path.join(
__dirname,
"views",
pages[Object.keys(req.query)[0]] || pages.index
)
res.send(
paintSource(
loadTemplates(
tryReadFile(
path.join(__dirname,
'views',
// Return the error page if the query is not found, as there is no
// undefined page in routes.mjs. Also set index as the default page.
'/?'.indexOf(req.url) ? pages[Object.keys(req.query)[0]] || 'error.html' : pages.index
)
)
)
)
)
)
)
);


app.use(router);
app.use(express.static(path.join(__dirname, "views")));
app.use("/uv/", express.static(uvPath));
Expand All @@ -122,6 +122,7 @@ app.use("/baremux/", express.static(baremuxPath));

app.disable("x-powered-by");

// Redundant code since 404 is handled elsewhere; left here as insurance.
app.use((req, res) => {
res.status(404).send(paintSource(loadTemplates(text404)));
});
Expand Down

0 comments on commit 8617872

Please sign in to comment.