1007app.get("/", (c) => c.html(html));
10081009// Export app.fetch for Val Town, otherwise export app
1010export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
1011
blob_adminmain.tsx22 matches
233const [isDragging, setIsDragging] = useState(false);
234235const fetchBlobs = useCallback(async () => {
236setLoading(true);
237try {
238const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
239const data = await response.json();
240setBlobs(data);
241} catch (error) {
242console.error("Error fetching blobs:", error);
243} finally {
244setLoading(false);
247248useEffect(() => {
249fetchBlobs();
250}, [fetchBlobs]);
251252const handleSearch = (e) => {
263setBlobContentLoading(true);
264try {
265const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
266const content = await response.text();
267setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
268setEditContent(content);
269} catch (error) {
270console.error("Error fetching blob content:", error);
271} finally {
272setBlobContentLoading(false);
277const handleSave = async () => {
278try {
279await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
280method: "PUT",
281body: editContent,
289const handleDelete = async (key) => {
290try {
291await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
292setBlobs(blobs.filter(b => b.key !== key));
293if (selectedBlob && selectedBlob.key === key) {
306const key = `${searchPrefix}${file.name}`;
307formData.append("key", encodeKey(key));
308await fetch("/api/blob", { method: "POST", body: formData });
309const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
310setBlobs([newBlob, ...blobs]);
314}
315}
316fetchBlobs();
317};
318328try {
329const fullKey = `${searchPrefix}${key}`;
330await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
331method: "PUT",
332body: "",
343const handleDownload = async (key) => {
344try {
345const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
346const blob = await response.blob();
347const url = window.URL.createObjectURL(blob);
362if (newKey && newKey !== oldKey) {
363try {
364const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
365const content = await response.blob();
366await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
367method: "PUT",
368body: content,
369});
370await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
371setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
372if (selectedBlob && selectedBlob.key === oldKey) {
382const newKey = `__public/${key}`;
383try {
384const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
385const content = await response.blob();
386await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
387method: "PUT",
388body: content,
389});
390await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
391setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
392if (selectedBlob && selectedBlob.key === key) {
401const newKey = key.slice(9); // Remove "__public/" prefix
402try {
403const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
404const content = await response.blob();
405await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
406method: "PUT",
407body: content,
408});
409await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
410setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
411if (selectedBlob && selectedBlob.key === key) {
chatgptchessmain.tsx3 matches
3637const { Chess } = await import("https://esm.sh/chess.js@1.0.0-beta.8")
38const position = (await fetch(`/game/${game_id}`).then(r => r.json())).fen
39const thinking = document.querySelector("#thinking")
40thinking.className = "transition-opacity opacity-0"
69thinking.className = "transition-opacity opacity-100"
7071const response = fetch(`/game/${game_id}`, {
72method: "POST",
73body: JSON.stringify({ san: move.san }),
278})
279280export default app.fetch
1/** @jsxImportSource npm:hono/jsx */
2import { fetch } from "https://esm.town/v/std/fetch";
3import { faker } from "npm:@faker-js/faker";
4import CryptoJS from "npm:crypto-js";
14"sec-ch-ua-mobile": "?0",
15"sec-ch-ua-platform": "\"Windows\"",
16"sec-fetch-dest": "empty",
17"sec-fetch-mode": "cors",
18"sec-fetch-site": "same-origin",
19"Referrer-Policy": "strict-origin-when-cross-origin",
20};
58}
59async function upload(formData: any, user: string) {
60const _ = await fetch("https://workers.cloudflare.com/playground/api/worker", {
61"headers": {
62...commonHeaders,
75app.get("/regUser", async (c) => {
76const uuid = await uuidGen();
77const uid = await fetch("https://workers.cloudflare.com/playground", {
78"headers": {
79"accept":
123headers: {
124"User-Agent": faker.internet.userAgent(),
125"Sec-Fetch-Dest": "iframe",
126"referer": "https://workers.cloudflare.com/",
127"Cookie": `token=${token}`,
153);
154});
155export default app.fetch;
immaculateTanMoosemain.tsx2 matches
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
23import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
137});
138139export default modifyFetchHandler(passwordAuth(app.fetch));
95const getVQD = async () => {
96try {
97const response = await fetch(STATUS_URL, {
98headers: {
99"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.3",
102});
103104console.log('VQD Fetch Headers:', Object.fromEntries(response.headers.entries()));
105const newVQD = response.headers.get('x-vqd-4') || '';
106console.log('Fetched VQD:', newVQD);
107setVqd(newVQD);
108return newVQD;
109} catch (error) {
110console.error('VQD Fetch Error:', error);
111return '';
112}
125let currentVQD = vqd || await getVQD();
126
127const response = await fetch(CHAT_URL, {
128method: 'POST',
129headers: {
381if (request.url.includes('/api/status')) {
382try {
383const statusResponse = await fetch('https://duckduckgo.com/duckchat/v1/status', {
384headers: {
385"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.3",
400} catch (error) {
401console.error('Status Proxy Error:', error);
402return new Response(JSON.stringify({ error: 'Failed to fetch VQD' }), {
403status: 500,
404headers: {
413try {
414const requestBody = await request.json();
415const chatResponse = await fetch('https://duckduckgo.com/duckchat/v1/chat', {
416method: 'POST',
417headers: {
PSEoutagesmain.tsx4 matches
35}
3637// ----- fetch or read from file
3839async function fetchOutages() {
40const res = await fetch(OUTAGES_URL);
41const json = await res.json();
42return json as OutagesJson;
101export async function getOutages() {
102// const outagesJson = await readOutages();
103const outagesJson = await fetchOutages();
104105// Create check
sqlite_adminmain.tsx1 match
10app.get("/", async (c) => c.html(await sqlite_admin_tables()));
11app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
12export default basicAuth(app.fetch, { verifyUser: (_, password) => verifyToken(password) });
enchantingSilverPelicanmain.tsx4 matches
1import { email } from "https://esm.town/v/std/email?v=9";
23// Fetches a random joke.
4function fetchRandomJoke() {
5const response = fetch(
6"https://official-joke-api.appspot.com/random_joke",
7);
9}
1011const randomJoke = fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;