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

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