slige/web/main.ts
2024-11-21 04:12:07 +01:00

23 lines
455 B
TypeScript

import { Application, Router } from "jsr:@oak/oak";
const app = new Application();
const router = new Router();
app.use(router.routes());
app.use(router.allowedMethods());
app.use(async (ctx, next) => {
try {
await ctx.send({ root: "./public", index: "index.html" });
} catch {
next();
}
});
const port = 8000;
const listener = app.listen({ port });
console.log(`Listening at http://localhost:${port}/`);
await listener;