Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Last active October 11, 2020 09:27
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 netsi1964/ee2ad2be6afee49cdcfa96cdc8c5ad68 to your computer and use it in GitHub Desktop.
Save netsi1964/ee2ad2be6afee49cdcfa96cdc8c5ad68 to your computer and use it in GitHub Desktop.
Build on deno.land script found here https://dev.to/aralroca/learn-deno-chat-app-37f0
/**
* webserver.ts
*/
import { serve } from "https://deno.land/std@0.74.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 });
}
@netsi1964
Copy link
Author

netsi1964 commented Oct 11, 2020

You can run this script from the terminal using
deno run --allow-net https://gist.githubusercontent.com/netsi1964/ee2ad2be6afee49cdcfa96cdc8c5ad68/raw/f49417d0344bfd0c0b5b135f28afe880cab3ef0c/deno-simple-web-server.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment