Skip to content

Instantly share code, notes, and snippets.

@grant
Last active March 8, 2021 18:17
Show Gist options
  • Save grant/ff863b49b3eca3522b7f2a2d6af3584d to your computer and use it in GitHub Desktop.
Save grant/ff863b49b3eca3522b7f2a2d6af3584d to your computer and use it in GitHub Desktop.
import { serve } from "https://deno.land/std@0.89.0/http/server.ts";
import "https://deno.land/x/dotenv/mod.ts";
const PORT = Deno.env.get('PORT') || 8080;
const s = serve(`0.0.0.0:${PORT}`);
const body = new TextEncoder().encode("Hello, Deno\n");
console.log(`Server started on port ${PORT}`);
for await (const req of s) {
req.respond({ body });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment