const PORT = 3000 Bun.serve({ port: PORT, async fetch(request, _server) { const url = new URL(request.url) if (url.pathname === '/') { return new Response(Bun.file("./index.html")) } if (url.pathname.endsWith(".css")) { return new Response(Bun.file(`.${url.pathname}`)) } if (url.pathname.endsWith(".jpg")) { return new Response(Bun.file(`.${url.pathname}`)) } const urlPath = `./src/${url.pathname}.js` const file = Bun.file(urlPath) if (!(await file.exists())) { console.log('here: ', urlPath) return new Response(Bun.file("./404.html")) } return new Response(file, { headers: { "Content-Type": "text/javascript;charset=UTF-8" } }) } })