cerebras_codermain.tsx1 match
2324try {
25const response = await fetch("/", {
26method: "POST",
27body: JSON.stringify({ prompt, currentCode: code }),
11const start = performance.now();
12try {
13const res = await fetch(url);
14end = performance.now();
15status = res.status;
22} catch (e) {
23end = performance.now();
24reason = `couldn't fetch: ${e}`;
25ok = false;
26console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
weatherGPTmain.tsx1 match
4let location = "brooklyn ny";
5let lang = "en";
6const weather = await fetch(
7`https://wttr.in/${location}?lang=${lang}&format=j1`,
8).then(r => r.json());
lovelyYellowXerinaemain.tsx18 matches
187}
188189// Updated function to fetch and parse URL content
190async function fetchUrlContent(url) {
191try {
192console.log('Fetching URL:', url);
193const response = await fetch(url);
194if (!response.ok) {
195throw new Error(`HTTP error! status: ${response.status}`);
196}
197const html = await response.text();
198console.log('Fetched HTML length:', html.length);
199const root = parse(html);
200228return content;
229} catch (error) {
230console.error('Error fetching URL:', error);
231throw new Error(`Failed to fetch URL content: ${error.message}`);
232}
233}
483try {
484if (url.length > 0) {
485const response = await fetch('/fetch-url', {
486method: 'POST',
487headers: {
493if (!response.ok) {
494const errorData = await response.json();
495throw new Error(errorData.error || 'Failed to fetch URL content');
496}
497501502if (!contentToAnalyse || contentToAnalyse.trim().length === 0) {
503throw new Error('No content to analyse. The fetched content might be empty.');
504}
505509}
510511const analysisResponse = await fetch('/analyse', {
512method: 'POST',
513headers: {
713});
714715app.post('/fetch-url', async (c) => {
716const { url } = await c.req.json();
717
718try {
719console.log('Fetching URL:', url);
720const content = await fetchUrlContent(url);
721console.log('Fetched content length:', content.length);
722if (content.length > 100000) {
723return c.json({ error: "Content from URL is too long. Please try a different URL with less content." }, 400);
724}
725if (content.trim().length === 0) {
726return c.json({ error: "The fetched content is empty. Please try a different URL." }, 400);
727}
728return c.json({ content });
729} catch (error) {
730console.error('Error fetching URL:', error);
731return c.json({ error: error.message }, 400);
732}
734735export default async function(request: Request): Promise<Response> {
736return app.fetch(request);
737}
699}
700701// Fetch Inter font from CDN
702async function fetchFont(url: string) {
703const res = await fetch(url);
704return new Uint8Array(await res.arrayBuffer());
705}
707708709const dmMonoLight = await fetchFont(
710"https://cdn.jsdelivr.net/fontsource/fonts/dm-mono@latest/latin-300-normal.ttf"
711);
712const dmMonoRegular = await fetchFont(
713"https://cdn.jsdelivr.net/fontsource/fonts/dm-mono@latest/latin-400-normal.ttf"
714);
715const dmMonoMedium = await fetchFont(
716"https://cdn.jsdelivr.net/fontsource/fonts/dm-mono@latest/latin-500-normal.ttf"
717);
718const interLight = await fetchFont(
719"https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-300-normal.ttf"
720);
721const interRegular = await fetchFont(
722"https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-400-normal.ttf"
723);
724const interSemiBold = await fetchFont(
725"https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-600-normal.ttf"
726);
727const interMedium = await fetchFont(
728"https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-500-normal.ttf"
729);
730const ebGaramondMediumItalic = await fetchFont(
731"https://cdn.jsdelivr.net/fontsource/fonts/eb-garamond@latest/latin-500-italic.ttf"
732);
791}
792} catch (error) {
793console.error("Error fetching image from Val Town blob:", error);
794}
795}
1230}
1231} catch (error) {
1232console.error("Error fetching image from Val Town blob:", error);
1233}
1234}
19151916async function updateImageStats(url) {
1917const response = await fetch(url);
1918const blob = await response.blob();
1919const img = new Image();
19611962try {
1963const response = await fetch(imageUrlValue + '&nocache=true');
1964const blob = await response.blob();
1965const url = URL.createObjectURL(blob);
2038});
20392040// Export app.fetch for Val Town, otherwise export app — this is only for hono apps
2041export default (typeof Deno !== "undefined" && Deno.env.get("valtown") && Deno.env.get("mode") !== "local")
2042? app.fetch
2043: app;
2044
sqlite_adminmain.tsx1 match
9app.get("/", async (c) => c.html(await sqlite_admin_tables()));
10app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
11export default basicAuth(app.fetch);
sqliteExplorerAppmain.tsx1 match
150});
151152export default basicAuth(app.fetch);
2324useEffect(() => {
25const fetchCount = async () => {
26const response = await fetch("/visitor-count");
27if (response.ok) {
28const { count } = await response.json();
31};
3233fetchCount();
34}, []);
354243try {
44const response = await fetch(imageUrl);
45const blob = await response.blob();
46const url = window.URL.createObjectURL(blob);
14- EDM response: `https://sammeltassen-rijks.web.val.run/200738982?format=edm`
1516The val checks if the objects has additional parts, and fetches the information for those parts as well. This will slow down the val for large objects!
1718It then passes this on to [IIIF Builder](https://github.com/IIIF-Commons/iiif-builder) with some metadata to create a IIIF Presentation Manifest.
3536async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38method: "POST",
39headers: {
5051async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53method: "POST",
54headers: {