1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import createPlugin from "https://esm.sh/@extism/extism";
export default async function(req: Request): Promise<Response> {
const plugin = await createPlugin(
"https://cdn.modsurfer.dylibso.com/api/v1/module/d7c54420f559239689b0b3df41ab8a692d7450120397190cb1167dc05008f633.wasm",
{ useWasi: false },
);
const q = new URL(req.url).searchParams;
const input = JSON.stringify({
value: q.get("text"),
color: q.get("color"),
font_size: parseInt(q.get("font_size")),
});
const out = await plugin.call("image", input);
return new Response(out.bytes(), {
headers: { "Content-type": "image/png" },
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 7, 2024