Skip to main content
这段代码启动了一个监听 3000 端口的 HTTP 服务器。它对所有请求都返回状态为 200、内容为 "Welcome to Bun!"Response 详情请参阅 Bun.serve
https://mintcdn.com/ikxin/RzFFGbzo0-4huILA/icons/typescript.svg?fit=max&auto=format&n=RzFFGbzo0-4huILA&q=85&s=a3dffd2241f05776d3bd25171d0c5a79server.ts
const server = Bun.serve({
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
});

console.log(`Listening on ${server.url}`);