Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

std/http/mod.ts>serve

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function serve
import { serve } from "https://deno.land/std@0.39.0/http/mod.ts";

Create a HTTP server

import { serve } from "https://deno.land/std/http/server.ts";
const body = "Hello World\n";
const s = serve({ port: 8000 });
for await (const req of s) {
  req.respond({ body });
}

Parameters

addr: string | HTTPOptions