bombCycloneOutageTrackermain.tsx3 matches
2526useEffect(() => {
27async function fetchData() {
28const response = await fetch("/outages");
29const json = await response.json();
30let firstEntry: { i: number; time: number; date: Date } = { i: -1, time: Date.now(), date: new Date() };
92setOutageData(data);
93}
94fetchData();
95}, []);
96
website_Summarizermain.tsx16 matches
52}, []);
5354const fetchAndSummarize = async () => {
55if (!siteUrl) {
56setError("Please enter a valid site URL");
63setSiteInfo(null);
64setProgress(10);
65console.log("Starting fetchAndSummarize");
6667try {
68// 1) Fetch site data
69setProgress(30);
70console.log("Fetching site details");
71const siteResponse = await fetch(`/site-data?url=${encodeURIComponent(siteUrl)}`);
72if (!siteResponse.ok) {
73throw new Error(`Failed to fetch site details: ${siteResponse.statusText}`);
74}
75const siteData = await siteResponse.json();
76setSiteInfo(siteData);
77console.log("Site details fetched", siteData);
7879// 2) Summarize site content
80setProgress(60);
81console.log("Sending summary request");
82const summaryResponse = await fetch("/summarize", {
83method: "POST",
84headers: {
102console.log("Summarization complete");
103} catch (err) {
104console.error("Fetch Error:", err);
105setError(`Error: ${err.message}`);
106setLoading(false);
111const handleKeyDown = (event) => {
112if (event.key === "Enter" && !loading) {
113fetchAndSummarize();
114}
115};
138/>
139<button
140onClick={fetchAndSummarize}
141disabled={loading}
142className="bg-orange-500 text-white p-3 rounded-r-lg hover:bg-orange-600 disabled:opacity-50 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-orange-500"
271// Scrapes the HTML and returns minimal metadata
272if (request.method === "GET" && pathname === "/site-data") {
273console.log("Fetching site data");
274const siteUrl = searchParams.get("url");
275if (!siteUrl) {
281282try {
283// Fetch the HTML from the site
284const siteResponse = await fetch(siteUrl);
285if (!siteResponse.ok) {
286throw new Error(`Failed to fetch site: ${siteResponse.statusText}`);
287}
288const siteHtml = await siteResponse.text();
310});
311} catch (error) {
312console.error("Error fetching site data:", error);
313return new Response(JSON.stringify({ error: error.message }), {
314status: 500,
1const Config = {
2repository: 'e.erw.cc',
3FETCH_TIMEOUT: 3000, // 3 seconds timeout
4CACHE_DURATION: 1000 * 60 * 60 // 1 hour cache
5};
8const EPG_CACHE = new Map();
910async function timeoutFetch(request, timeout = Config.FETCH_TIMEOUT) {
11const controller = new AbortController();
12const timeoutId = setTimeout(() => controller.abort(), timeout);
1314try {
15const response = await fetch(request, {
16signal: controller.signal,
17headers: {
18'User-Agent': 'ValTown EPG Fetcher',
19'Accept': 'application/json'
20}
66
67try {
68const res = await timeoutFetch(new Request(`https://github.com/celetor/epg/releases/download/${tag}/112114.json`, request));
69const data = await res.json();
7096return makeRes(JSON.stringify(program_info), 200, { 'content-type': 'application/json' });
97} catch (error) {
98console.error('EPG Fetch Error:', error);
99return makeRes(JSON.stringify({
100date,
geminicodermain.tsx1 match
181182try {
183const response = await fetch("/", {
184method: "POST",
185body: JSON.stringify({
blog_test_25_1_11main.tsx8 matches
2324useEffect(() => {
25fetchPosts();
26}, []);
2728const fetchPosts = async () => {
29try {
30const response = await fetch("/api/posts");
31if (!response.ok) throw new Error("Failed to fetch posts");
32const data = await response.json();
33setPosts(data);
41const handleCreatePost = async (post: Omit<BlogPost, "id" | "date">) => {
42try {
43const response = await fetch("/api/posts", {
44method: "POST",
45headers: { "Content-Type": "application/json" },
47});
48if (!response.ok) throw new Error("Failed to create post");
49await fetchPosts();
50setIsFormOpen(false);
51} catch (err) {
56const handleUpdatePost = async (post: BlogPost) => {
57try {
58const response = await fetch(`/api/posts/${post.id}`, {
59method: "PUT",
60headers: { "Content-Type": "application/json" },
62});
63if (!response.ok) throw new Error("Failed to update post");
64await fetchPosts();
65setSelectedPost(null);
66setIsFormOpen(false);
blob_adminmain.tsx23 matches
234const [isDragging, setIsDragging] = useState(false);
235236const fetchBlobs = useCallback(async () => {
237setLoading(true);
238try {
239const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240const data = await response.json();
241setBlobs(data);
242} catch (error) {
243console.error("Error fetching blobs:", error);
244} finally {
245setLoading(false);
248249useEffect(() => {
250fetchBlobs();
251}, [fetchBlobs]);
252253const handleSearch = (e) => {
264setBlobContentLoading(true);
265try {
266const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267const content = await response.text();
268setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
269setEditContent(content);
270} catch (error) {
271console.error("Error fetching blob content:", error);
272} finally {
273setBlobContentLoading(false);
278const handleSave = async () => {
279try {
280await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281method: "PUT",
282body: editContent,
290const handleDelete = async (key) => {
291try {
292await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293setBlobs(blobs.filter(b => b.key !== key));
294if (selectedBlob && selectedBlob.key === key) {
307const key = `${searchPrefix}${file.name}`;
308formData.append("key", encodeKey(key));
309await fetch("/api/blob", { method: "POST", body: formData });
310const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311setBlobs([newBlob, ...blobs]);
315}
316}
317fetchBlobs();
318};
319329try {
330const fullKey = `${searchPrefix}${key}`;
331await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332method: "PUT",
333body: "",
344const handleDownload = async (key) => {
345try {
346const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347const blob = await response.blob();
348const url = window.URL.createObjectURL(blob);
363if (newKey && newKey !== oldKey) {
364try {
365const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366const content = await response.blob();
367await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368method: "PUT",
369body: content,
370});
371await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373if (selectedBlob && selectedBlob.key === oldKey) {
383const newKey = `__public/${key}`;
384try {
385const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386const content = await response.blob();
387await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388method: "PUT",
389body: content,
390});
391await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393if (selectedBlob && selectedBlob.key === key) {
402const newKey = key.slice(9); // Remove "__public/" prefix
403try {
404const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405const content = await response.blob();
406await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407method: "PUT",
408body: content,
409});
410await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412if (selectedBlob && selectedBlob.key === key) {
826});
827828export default lastlogin((request: Request) => app.fetch(request));
sqliteExplorerAppmain.tsx4 matches
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
23import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
cerebras_codermain.tsx1 match
182183try {
184const response = await fetch("/", {
185method: "POST",
186body: JSON.stringify({
searchClosestWikimain.tsx4 matches
1// Stripping HTML from the final output before sending the response
2import { fetch } from "https://esm.town/v/std/fetch";
34export const searchClosestWiki = async (req: Request) => {
18encodeURIComponent(searchQuery)
19}&srwhat=text&format=json&utf8=1&origin=*`;
20const searchResponse = await fetch(searchUrl);
21const searchData = await searchResponse.json();
2232encodeURIComponent(pageTitle)
33}&format=json&utf8=1&origin=*`;
34const contentResponse = await fetch(contentUrl);
35const contentData = await contentResponse.json();
36const pageId = Object.keys(contentData.query.pages)[0];
45});
46} catch (err) {
47return new Response(`Error fetching Wikipedia data: ${err.message}`, {
48status: 200, // Internal Server Error
49headers: { "Content-Type": "text/plain" },
competentMaroonFlymain.tsx1 match
182183try {
184const response = await fetch("/", {
185method: "POST",
186body: JSON.stringify({