Last active
October 11, 2020 09:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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