187
188 try {
189 const response = await fetch("/", {
190 method: "POST",
191 body: JSON.stringify({
17 setIsLoading(true);
18 try {
19 const response = await fetch('/extract', {
20 method: 'POST',
21 body: JSON.stringify({ text })
133})
134
135export default app.fetch;
48async function uploadImage(agent: AtpAgent, imageUrl: string) {
49 try {
50 // Fetch the image
51 const response = await fetch(imageUrl);
52 if (!response.ok) {
53 console.error(`Failed to fetch image: ${imageUrl}`);
54 return null;
55 }
187
188 try {
189 const response = await fetch("/", {
190 method: "POST",
191 body: JSON.stringify({
218 });
219 } catch (error) {
220 console.error("Error fetching messages:", error);
221 return new Response(
222 JSON.stringify({ error: "Failed to fetch messages" }),
223 { status: 500 },
224 );
379 const loadMessages = async () => {
380 try {
381 const response = await fetch("/messages");
382 if (!response.ok) {
383 throw new Error("Failed to fetch messages");
384 }
385 const data = await response.json();
386 setMessages(data);
387 } catch (error) {
388 console.error("Error fetching messages:", error);
389 setMessages([
390 {
406
407 try {
408 const response = await fetch("/chat", {
409 method: "POST",
410 headers: { "Content-Type": "application/json" },
14 // const imageUrl = "https://charlypoly-httpapiscreenshotpageexample.web.val.run/?url=" + url.origin;
15 // return Response.redirect(imageUrl, 302)
16 const res = await fetch(imageUrl);
17 const blob = await res.blob();
18 return new Response(blob, { headers: { "Content-Type": "image/png" } });
20 try {
21 // Use a more reliable GeoJSON source
22 const response = await fetch(
23 `https://raw.githubusercontent.com/datasets/geo-countries/master/data/countries.geojson`,
24 );
24 const fontUrl = "https://github.com/googlefonts/roboto/raw/main/src/hinted/Roboto-Regular.ttf";
25
26 // Fetch and parse the font
27 const fontResponse = await fetch(fontUrl);
28 const fontArrayBuffer = await fontResponse.arrayBuffer();
29
96
97 try {
98 console.log('Fetching image from:', imageUrl);
99 const response = await fetch(imageUrl);
100 if (!response.ok) {
101 throw new Error(`HTTP error! status: ${response.status}`);
144 let errorMessage = `Error processing image: ${error.message}. `;
145 if (error.message.includes('HTTP error')) {
146 errorMessage += 'The image could not be fetched from the provided URL. Please check if the URL is correct and accessible.';
147 } else if (error.message.includes('decode')) {
148 errorMessage += 'The image could not be decoded. Please ensure the URL points to a valid image file.';
149 } else if (error.message.includes('client error (Connect)')) {
150 errorMessage += 'There was a network error while trying to fetch the image. This might be due to network restrictions or the image server being unreachable.';
151 } else {
152 errorMessage += 'An unexpected error occurred while processing the image. Please try again or contact support if the issue persists.';