Deno standard library
Go to Latest
function serve
import { serve } from "";

Serves HTTP requests with the given handler.

You can specifies addr option, which is the address to listen on, in the form "host:port". The default is "".

The below example serves with the port 8000.

import { serve } from "";
serve((_req) => new Response("Hello, world"));

You can change the listening address by addr option. The below example serves with the port 3000.

import { serve } from "";
console.log("server is starting at localhost:3000");
serve((_req) => new Response("Hello, world"), { addr: ":3000" });


handler: Handler[src]

The handler for individual HTTP requests.

options: ServeInit

The options. See ServeInit documentation for details.