provideBlob
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
main.tsx
https://postpostscript--1b804cd0276011f086ff569c3dd06744.web.val.run
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>
`;
}
Migrated from folder: HTML/provideBlob