7
8async function renderImage(s: string, color: string) {
9 const fontArrayBuf = await fetch(
10 "https://cdn.jsdelivr.net/npm/roboto-font@0.1.0/fonts/Roboto/roboto-regular-webfont.ttf",
11 ).then((res) => res.arrayBuffer());
105});
106
107export default app.fetch;
63});
64
65export default app.fetch;
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5";
2
3export const webscrapeWikipediaIntro = (async () => {
4 const cheerio = await import("npm:cheerio");
5 const html = await fetchText(
6 "https://en.wikipedia.org/wiki/OpenAI",
7 );
1import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
2import { prettifyHtml } from "https://esm.town/v/neverstew/prettifyHtml";
3import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
4import { escape } from "npm:html-sloppy-escaper";
5
6export default modifyFetchHandler(async function(req: Request) {
7 const pathname = new URL(req.url).searchParams.get("url");
8 const html = await fetchText(pathname ?? "example.com"); // .then(prettifyHtml);
9 const body = `<html>
10 <head>
5 const search = `https://digitallibrary.un.org/search?p=${encodeURIComponent(symbol)}&rg=1&of=xm`;
6 try {
7 const response = await fetch(search);
8 const xmlData = await response.text();
9 const parser = new DOMParser();
5 const url = new URL(`${baseURL}/${procedure}`);
6 url.searchParams.set("input", JSON.stringify(input));
7 const resp = await fetch(url, {
8 headers: {
9 authorization: `Bearer ${Deno.env.get("valtown")}`,
17 },
18 async mutate<T = any>(procedure: string, input: Record<string, unknown>) {
19 const resp = await fetch(new URL(`${baseURL}/${procedure}`), {
20 method: "POST",
21 headers: {
9 let reason: string;
10 try {
11 const res = await fetch(URL, { redirect: "follow" });
12 if (res.status !== 200) {
13 reason = `(status code: ${res.status})`;
15 }
16 } catch (e) {
17 reason = `couldn't fetch: ${e}`;
18 ok = false;
19 }
5async function createScreenshot(code: string) {
6 const apiUrl = "https://sourcecodeshots.com/api/image";
7 const resp = await fetch(apiUrl, {
8 method: "POST",
9 headers: {
39 }
40 }
41 const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`, {
42 headers,
43 });
49 if (url.searchParams.has("v")) {
50 const version = url.searchParams.get("v");
51 const resp = await fetch(
52 `https://api.val.town/v1/vals/${val.id}/versions/${version}`,
53 { headers },
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=43";
2
3console.log(
4 await fetchJSON(
5 `https://api.val.town/v1/vals/1f32d4c1-332e-4135-889f-8df408924a9d/versions/1`,
6 {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=43";
2
3console.log(await fetchJSON("https://api.val.town/v1/alias/stevekrouse/fetchJSON"));