Public
HTTP (deprecated)
  • postpostscript avatar
    provideBlob
    @postpostscript
    provideBlob: Return Response Quickly and Poll for the Expensive Parts Example: See @postpostscript/provideBlobExample for full example. You will need to fork this val to use provideBlob on your projects as it uses @std/blob for storage import { Image } from "https://deno.land/x/imagescript@1.2.17/mod.ts"; import { htmlResponse } from "https://esm.town/v/postpostscript/html"; import { provideBlob } from "https://esm.town/v/postpostscript/provideBlob"; export default async function(req: Request) { const image = provideBlob(async () => { const png = new Image(100, 100); png.drawCircle(50, 50, 50, 100); return png.encode(); }).jsPromise(); return htmlResponse` <div id="image"></div> <script> ${image}.then(blob => { const $img = document.createElement("img") $img.src = URL.createObjectURL(blob) document.getElementById("image").appendChild($img) }) </script> `; }
    HTTP (deprecated)
  • postpostscript avatar
    html
    @postpostscript
    html: create sanitized HTML using tagged templates Examples import { html } from "https://esm.town/v/postpostscript/html" const unsafeInput = "<script>alert(1)</script>" console.log(html`Value: ${unsafeInput}`) // Value: &lt;script&gt;alert(1)&lt;/script&gt; These can be combined -- HTML marked as safe (instance is RawHTML ) will be directly inserted: const scripts = html`<script>alert(1)</script>` console.log(html`<head> ${scripts} </head>`.toString()) // <head> // <script>alert(1)</script> // </head> To easily create HTTP Response outputs like @stevekrouse/html, use the htmlResponse utility: import { html, htmlResponse } from "https://esm.town/v/postpostscript/html"; export default function(req: Request) { return htmlResponse` Request URL: ${decodeURIComponent(req.url)} `; } Tests: @postpostscript/htmlTest
    Script
1
Next
postpostscript-provideblobexample.web.val.run
February 29, 2024