blob_admin_migratedmain.tsx25 matches
73const menuRef = useRef(null);
74const isPublic = blob.key.startsWith("__public/");
75const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
7677useEffect(() => {
237setLoading(true);
238try {
239const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240const data = await response.json();
241setBlobs(data);
264setBlobContentLoading(true);
265try {
266const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267const content = await response.text();
268setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
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]);
329try {
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) {
557onClick={() =>
558copyToClipboard(
559`${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
560)}
561className="text-blue-400 hover:text-blue-300 text-sm"
580>
581<img
582src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
583alt="Blob content"
584className="max-w-full h-auto"
660661// Public route without authentication
662app.get("/api/public/:id", async (c) => {
663const key = `__public/${c.req.param("id")}`;
664const { blob } = await import("https://esm.town/v/std/blob");
766};
767768app.get("/api/blobs", checkAuth, async (c) => {
769const prefix = c.req.query("prefix") || "";
770const limit = parseInt(c.req.query("limit") || "20", 10);
775});
776777app.get("/api/blob", checkAuth, async (c) => {
778const key = c.req.query("key");
779if (!key) return c.text("Missing key parameter", 400);
783});
784785app.put("/api/blob", checkAuth, async (c) => {
786const key = c.req.query("key");
787if (!key) return c.text("Missing key parameter", 400);
792});
793794app.delete("/api/blob", checkAuth, async (c) => {
795const key = c.req.query("key");
796if (!key) return c.text("Missing key parameter", 400);
800});
801802app.post("/api/blob", checkAuth, async (c) => {
803const { file, key } = await c.req.parseBody();
804if (!file || !key) return c.text("Missing file or key", 400);
sqliteExplorerAppREADME.md1 match
13## Authentication
1415Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
1617## Todos / Plans
sqliteExplorerAppmain.tsx2 matches
27<head>
28<title>SQLite Explorer</title>
29<link rel="preconnect" href="https://fonts.googleapis.com" />
3031<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32<link
33href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34rel="stylesheet"
35/>
versatileWhiteJaymain.tsx7 matches
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45// TMDB API Configuration
6const TMDB_API_KEY = "3fd2be6f0c70a2a598f084ddfb75487c"; // Public read-only key
7const TMDB_BASE_URL = "https://api.themoviedb.org/3";
8const TMDB_IMAGE_BASE_URL = "https://image.tmdb.org/t/p/w500";
945async () => {
46const response = await fetch(
47`${TMDB_BASE_URL}/search/person?api_key=${TMDB_API_KEY}&query=${encodeURIComponent(searchTerm)}&language=en-US&page=1`
48);
49const data = await response.json();
54const alternativeSearches = INDIAN_FILM_KEYWORDS.map(async (keyword) => {
55const response = await fetch(
56`${TMDB_BASE_URL}/search/person?api_key=${TMDB_API_KEY}&query=${encodeURIComponent(`${searchTerm} ${keyword}`)}&language=en-US&page=1`
57);
58const data = await response.json();
108async () => {
109const response = await fetch(
110`${TMDB_BASE_URL}/person/${actorId}/movie_credits?api_key=${TMDB_API_KEY}&language=en-US`
111);
112const data = await response.json();
118INDIAN_LANGUAGES.map(async (lang) => {
119const response = await fetch(
120`${TMDB_BASE_URL}/discover/movie?api_key=${TMDB_API_KEY}&with_cast=${actorId}&with_original_language=${lang}&sort_by=popularity.desc`
121);
122const data = await response.json();
835<head>
836<title>🌽 Kernel CRM</title>
837<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
838<style>${css}</style>
839<meta name="viewport" content="width=device-width, initial-scale=1" />
OpenTownieREADME.md3 matches
10## Getting Started
11121. Create a [Val Town API token](https://www.val.town/settings/api) with Val read and write permissions
132. Paste the token into the input box and get started
1415## Forking the Project
1617You'll need to get an **Open Router API key**.
18We choose Open Router so we could easily switch between
19all models. We soon want to make it so you can choose your
20model from a dropdown, but we're having trouble formatting the api calls such that they work on all providers. Maybe we need to switch to the vercel sdk
OpenTowniesystem_prompt.txt2 matches
26* DO NOT use the alert(), prompt(), or confirm() methods.
2728* If the user's app needs weather data, use open-meteo unless otherwise specified because it doesn't require any API keys.
2930* Tastefully add a view source link back to the user's val if there's a natural spot for it. Generate the val source url via `import.meta.url.replace("esm.town", "val.town")`. This link element should include a target="_top" attribute.
38Val Town's client-side catch script automatically catches client-side errors to aid in debugging.
3940* Don't use any environment variables unless strictly necessary. For example use APIs that don't require a key.
41If you need environment variables use `Deno.env.get('keyname')`
42
OpenTowniegenerateCode2 matches
2930const openai = new OpenAI({
31baseURL: "https://openrouter.ai/api/v1",
32apiKey: Deno.env.get("OPEN_ROUTER_KEY"),
33});
34console.log(messages);
ThumbMakermain.tsx1 match
2* This application creates a thumbnail maker using Hono for server-side routing and client-side JavaScript for image processing.
3* It allows users to upload images, specify output options, and generate a composite thumbnail image.
4* The app uses the HTML5 Canvas API for image manipulation and supports drag-and-drop functionality.
5*
6* The process is divided into two steps:
createWebsitemain.tsx5 matches
45// Utility Functions
6const API_BASE_URL = 'https://api.example.com';
78// Components
68e.preventDefault();
69try {
70const response = await fetch(`${API_BASE_URL}/login`, {
71method: 'POST',
72headers: { 'Content-Type': 'application/json' },
121122try {
123const response = await fetch(`${API_BASE_URL}/signup`, {
124method: 'POST',
125headers: { 'Content-Type': 'application/json' },
181182try {
183const response = await fetch(`${API_BASE_URL}/upload`, {
184method: 'POST',
185body: formData
215216try {
217const response = await fetch(`${API_BASE_URL}/chat`, {
218method: 'POST',
219headers: { 'Content-Type': 'application/json' },