Skip to content

Instantly share code, notes, and snippets.

@jbergant
Created June 5, 2020 18:19
Show Gist options
  • Select an option

  • Save jbergant/6a2b304c38e905a33f5b144e192ef189 to your computer and use it in GitHub Desktop.

Select an option

Save jbergant/6a2b304c38e905a33f5b144e192ef189 to your computer and use it in GitHub Desktop.
deno server with env variables
import { serve } from "https://deno.land/std/http/server.ts";
const env = Deno.env.toObject();
const PORT = Number(env.PORT) || 8000;
const HOST = env.HOST || "localhost";
const server = serve({ hostname: HOST, port: PORT });
console.log(`http://${HOST}:${PORT}`);
for await (const req of server) {
req.respond({ body: "Hello World\n" });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment