8 const [notification, setNotification] = React.useState({ show: false, message: "", type: "" });
9
10 const fetchWebhooks = async () => {
11 setLoading(true);
12 // Commented out for now as per original code
13 // try {
14 // const response = await fetch("/getWebhooks");
15 // const data = await response.json();
16 // setWebhooks(data);
17 // } catch (error) {
18 // console.error("Failed to fetch webhooks", error);
19 // showNotification("Failed to load webhooks", "error");
20 // }
38
39 const handleWebhookSubmit = () => {
40 fetchWebhooks();
41 showNotification("Webhook registered successfully!");
42 };
43
44 React.useEffect(() => {
45 fetchWebhooks();
46 }, []);
47
30
31 try {
32 const response = await fetch("/submit-webhook", {
33 method: "POST",
34 headers: { "Content-Type": "application/json" },
24 try {
25 const logEndpoint = "https://dcm31-pdf2vector-logger.web.val.run/";
26 await fetch(logEndpoint, {
27 method: "POST",
28 body: `SVG Store: ${info}`,
171 formData.append('svg', file);
172
173 const response = await fetch('', {
174 method: 'POST',
175 body: formData
211 if (confirm('Are you sure you want to delete this SVG?')) {
212 try {
213 const response = await fetch('/' + id, {
214 method: 'DELETE'
215 });
256
257 // Send to server
258 fetch('/errors', {
259 method: 'POST',
260 headers: { 'Content-Type': 'application/json' },
415 // Store SVG on server
416 try {
417 const response = await fetch('/store-svg', {
418 method: 'POST',
419 headers: { 'Content-Type': 'application/json' },
473
474 // Log detailed error to server
475 fetch('/errors', {
476 method: 'POST',
477 headers: { 'Content-Type': 'application/json' },
726});
727
728export default app.fetch;
152 payload.embeds.push(summaryEmbed);
153
154 const response = await fetch(discordWebhookUrl, {
155 method: "POST",
156 headers: {
201 };
202
203 const response = await fetch(telegramApiUrl, {
204 method: "POST",
205 headers: {
138 };
139
140 const response = await fetch(discordWebhookUrl, {
141 method: "POST",
142 headers: {
179 };
180
181 const response = await fetch(telegramApiUrl, {
182 method: "POST",
183 headers: {
11import { encode as base64Encode } from "https://deno.land/std@0.177.0/encoding/base64.ts";
12
13// Function to fetch and encode an external image
14async function fetchAndEncodeImage(url) {
15 try {
16 const response = await fetch(url);
17 if (!response.ok) {
18 throw new Error(`Failed to fetch image: ${response.status} ${response.statusText}`);
19 }
20 const arrayBuffer = await response.arrayBuffer();
22 return base64Encode(uint8Array);
23 } catch (error) {
24 console.error("Error fetching external image:", error);
25 throw error;
26 }
48 const userImageBase64 = base64Encode(uint8Array);
49
50 // Fetch and encode the scientist image
51 const scientistImageUrl = "https://pbs.twimg.com/media/GdMjZhubYAAM1Yf?format=jpg&name=4096x4096";
52 const scientistImageBase64 = await fetchAndEncodeImage(scientistImageUrl);
53
54 console.log("Processing images with Gemini 2.0 Flash Experimental...");
330 formData.append('prompt', this.prompt);
331
332 const response = await fetch('/edit-image', {
333 method: 'POST',
334 body: formData
505app.post("/edit-image", imageEditHandler);
506
507export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
508
509
236 ].filter(Boolean).join(" ");
237
238 const response = await fetch("/apply", {
239 method: "POST",
240 headers: { "Content-Type": "application/json" },
42 if (licenseKey === ADMIN_KEY) {
43 setViewMode('admin');
44 // Fetch existing signals for admin
45 try {
46 const signalsResponse = await fetch('/get-signals', {
47 method: 'POST',
48 headers: {
62 try {
63 // For public and VIP keys
64 const signalsResponse = await fetch('/get-signals', {
65 method: 'POST',
66 headers: {
97
98 try {
99 const response = await fetch('/add-signals', {
100 method: 'POST',
101 headers: {
112 setNewSignals('');
113 // Reload signals in admin view
114 const signalsResponse = await fetch('/get-signals', {
115 method: 'POST',
116 headers: {
134
135 try {
136 const response = await fetch('/clear-signals', {
137 method: 'POST',
138 headers: {
6
7export const sendMessage = async (body: Payload) => {
8 const res = await fetch(Deno.env.get("SLACK_WEBHOOK_URL"), {
9 method: "POST",
10 body: JSON.stringify(body),
20 };
21
22 const response = await fetch("https://slack.com/api/chat.postMessage", {
23 method: "POST",
24 headers: {