Skip to content

Instantly share code, notes, and snippets.

@lucacasonato
Last active June 2, 2020 20:09
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 lucacasonato/8688e850e0493b5fe6530240c0310dca to your computer and use it in GitHub Desktop.
Save lucacasonato/8688e850e0493b5fe6530240c0310dca to your computer and use it in GitHub Desktop.
Read text from body
import { serve } from "https://deno.land/std@0.55.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
const decoder = new TextDecoder();
for await (const req of s) {
const body = await Deno.readAll(req.body);
const str = decoder.decode(body);
console.log(`Body: ${str}`);
req.respond({ body: str });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment