logoDenoby example



HTTP Server: Hello World


An example of a HTTP server that serves a "Hello World" message.

HTTP servers need a handler function. This function is called for every request that comes in. It must return a `Response`. The handler function can be asynchronous (it may return a `Promise`).
function handler(_req: Request): Response {
  return new Response("Hello, World!");
To start the server on the default port, call `Deno.serve` with the handler.

Run this example locally using the Deno CLI:

deno run --allow-net https://examples.deno.land/http-server.ts

Try this example in a Deno Deploy playground:

Additional resources: