Deno logoDenoby example



HTTP Server: Hello World

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

Import the http server from std/http.
import { serve } from "";
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 `serve` with the handler.
console.log("Listening on http://localhost:8000");

Run this example locally using the Deno CLI:

deno run --allow-net

Try this example in a Deno Deploy playground:

Additional resources: