Skip to content

Commit

Permalink
no .html
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNotSus committed Jan 4, 2025
1 parent 8fe29a5 commit e2471d7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ app.use((req, res, next) => {
next();
});
const apiKeys = [process.env.API_KEY, process.env.API_KEY1];
randomAPIKey =
apiKeys[Math.floor(Math.random() * apiKeys.length)];
randomAPIKey = apiKeys[Math.floor(Math.random() * apiKeys.length)];

app.post("/api/chat", async (req, res) => {
const { message, userId } = req.body;
Expand Down Expand Up @@ -318,6 +317,18 @@ app.post("/api/readSave", async (req, res) => {
// next();
// });
app.use(express.static(path.join(__dirname, "static")));
app.use((req, res, next) => {
if (req.method === "GET" && !path.extname(req.url)) {
const filePath = path.join(__dirname, "static", req.url + ".html");
res.sendFile(filePath, (err) => {
if (err) {
next();
}
});
} else {
next();
}
});

const routes = [
{ path: "/a", file: "apps.html" },
Expand Down

0 comments on commit e2471d7

Please sign in to comment.