Skip to content

Instantly share code, notes, and snippets.

@ianaya89
Created November 26, 2020 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianaya89/d6e3c532066efc4ce50251d9f48c4722 to your computer and use it in GitHub Desktop.
Save ianaya89/d6e3c532066efc4ce50251d9f48c4722 to your computer and use it in GitHub Desktop.
import { serve } from "https://deno.land/std@0.79.0/http/server.ts";
const server = serve({ hostname: "0.0.0.0", port: 8080 });
console.log(`HTTP webserver running. Access it at: http://localhost:8080/`);
for await (const request of server) {
let bodyContent = "Your user-agent is:\n\n";
bodyContent += request.headers.get("user-agent") || "Unknown";
request.respond({ status: 200, body: bodyContent });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment