Last active
June 2, 2020 20:09
-
-
Save lucacasonato/8688e850e0493b5fe6530240c0310dca to your computer and use it in GitHub Desktop.
Read text from body
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
import { serve } from "https://deno.land/[email protected]/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