aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/http/simple.md
blob: be5147541def6d6edd9521188fab1d9af1077ec4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
---
name: Write a simple HTTP server
---

This starts an HTTP server listening on port `3000`. It responds to all requests with a `Response` with status `200` and body `"Welcome to Bun!"`.

See [`Bun.serve`](/docs/api/http) for details.

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

console.log(`Listening on localhost:\${server.port}`);
```