Skip to main content

Write a simple HTTP server

还没翻译译自英文(bun.com)本页 3 段都还没译

This code starts an HTTP server listening on port 3000. It responds to every request with a 200 status and the body "Welcome to Bun!".

See Bun.serve for details.

const server = Bun.serve({
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
});

console.log(`Listening on ${server.url}`);
번역 © 2026 fanyi.dev · 원문 © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)