NOTICE: 2021/04/09 no longer hosts typescript files. Use

Server API

Server API is low level HTTP interface for building customized HTTP server.

All HTTP requests connected to the address will be passed to callback function. Serve API automatically manages Keep-Alive connection and process requests from same connection serially.

import { listenAndServe } from "[email protected]/mod.ts";
const listener = listenAndServe({ port: 8899 }, async (req) => {
  await req.respond({
    status: 200,
    headers: new Headers({
      "content-type": "text/plain",
    body: "hello",