blob_adminmain.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);
cerebras_coderREADME.md2 matches
671. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
cerebras_codermain.tsx5 matches
212} catch (error) {
213Toastify({
214text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215position: "center",
216duration: 3000,
1024};
1025} else {
1026const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027const completion = await client.chat.completions.create({
1028messages: [
1149<meta name="viewport" content="width=device-width, initial-scale=1.0">
1150<title>CerebrasCoder</title>
1151<link rel="preconnect" href="https://fonts.googleapis.com" />
1152<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153<link
1154href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155rel="stylesheet"
1156/>
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
tasks_test1main.tsx10 matches
166167const fetchTasks = async () => {
168const response = await fetch('/api/tasks');
169const fetchedTasks = await response.json();
170setTasks(fetchedTasks);
188if (newTask.text.trim() && newTask.dueDate) {
189try {
190const response = await fetch('/api/tasks', {
191method: 'POST',
192headers: { 'Content-Type': 'application/json' },
206const handleDeleteTask = async (taskId) => {
207try {
208const response = await fetch(`/api/tasks/${taskId}`, { method: 'DELETE' });
209if (response.ok) {
210fetchTasks();
224if (taskToEdit.text.trim() && taskToEdit.dueDate) {
225try {
226const response = await fetch(`/api/tasks/${taskToEdit.id}`, {
227method: 'PUT',
228headers: { 'Content-Type': 'application/json' },
242const handleToggleTaskCompletion = async (taskId, done) => {
243try {
244const response = await fetch(`/api/tasks/${taskId}`, {
245method: 'PATCH',
246headers: { 'Content-Type': 'application/json' },
577578const url = new URL(request.url);
579if (url.pathname === '/api/tasks' && request.method === 'GET') {
580const tasks = await sqlite.execute(`SELECT * FROM ${KEY}_tasks_${SCHEMA_VERSION}`);
581return new Response(JSON.stringify(tasks.rows), { headers: { 'Content-Type': 'application/json' } });
582} else if (url.pathname === '/api/tasks' && request.method === 'POST') {
583const { text, done, dueDate } = await request.json();
584await sqlite.execute(`INSERT INTO ${KEY}_tasks_${SCHEMA_VERSION} (text, done, dueDate) VALUES (?, ?, ?)`, [text, done ? 1 : 0, dueDate]);
585return new Response(null, { status: 201 });
586} else if (url.pathname.startsWith('/api/tasks/') && request.method === 'DELETE') {
587const id = url.pathname.split('/').pop();
588await sqlite.execute(`DELETE FROM ${KEY}_tasks_${SCHEMA_VERSION} WHERE id = ?`, [id]);
589return new Response(null, { status: 204 });
590} else if (url.pathname.startsWith('/api/tasks/') && request.method === 'PUT') {
591const id = url.pathname.split('/').pop();
592const { text, done, dueDate } = await request.json();
593await sqlite.execute(`UPDATE ${KEY}_tasks_${SCHEMA_VERSION} SET text = ?, done = ?, dueDate = ? WHERE id = ?`, [text, done ? 1 : 0, dueDate, id]);
594return new Response(null, { status: 204 });
595} else if (url.pathname.startsWith('/api/tasks/') && request.method === 'PATCH') {
596const id = url.pathname.split('/').pop();
597const { done } = await request.json();
helpfulTealTapirREADME.md2 matches
671. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
helpfulTealTapirmain.tsx5 matches
212} catch (error) {
213Toastify({
214text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215position: "center",
216duration: 3000,
1024};
1025} else {
1026const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027const completion = await client.chat.completions.create({
1028messages: [
1149<meta name="viewport" content="width=device-width, initial-scale=1.0">
1150<title>CerebrasCoder</title>
1151<link rel="preconnect" href="https://fonts.googleapis.com" />
1152<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153<link
1154href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155rel="stylesheet"
1156/>
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
vigilantAmaranthDragonflyREADME.md2 matches
671. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
vigilantAmaranthDragonflymain.tsx5 matches
212} catch (error) {
213Toastify({
214text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215position: "center",
216duration: 3000,
1024};
1025} else {
1026const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027const completion = await client.chat.completions.create({
1028messages: [
1149<meta name="viewport" content="width=device-width, initial-scale=1.0">
1150<title>CerebrasCoder</title>
1151<link rel="preconnect" href="https://fonts.googleapis.com" />
1152<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153<link
1154href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155rel="stylesheet"
1156/>
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
protectiveWhiteToadmain.tsx5 matches
212} catch (error) {
213Toastify({
214text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215position: "center",
216duration: 3000,
1024};
1025} else {
1026const client = new Cerebras({ apiKey: Deno.env.get("vishu_singh") });
1027const completion = await client.chat.completions.create({
1028messages: [
1149<meta name="viewport" content="width=device-width, initial-scale=1.0">
1150<title>CerebrasCoder</title>
1151<link rel="preconnect" href="https://fonts.googleapis.com" />
1152<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153<link
1154href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155rel="stylesheet"
1156/>
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
protectiveWhiteToadREADME.md2 matches
671. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`