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

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