Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=function&page=1222&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 17278 results for "function"(1779ms)

1
2 export default function handler(req) {
3 return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n </style>\n </head>\n <body>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">export default function handler(req) {\n return new Response(\n &lt;!DOCTYPE html&gt;\n &lt;html&gt;\n &lt;head&gt;\n &lt;title&gt;Claude Chat Conversation&lt;/title&gt;\n &lt;meta charset=&quot;UTF-8&quot;&gt;\n &lt;style&gt;\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n &lt;/style&gt;\n &lt;/head&gt;\n &lt;body&gt; &lt;div class=&quot;message human&quot;&gt;\n &lt;div class=&quot;role&quot;&gt;Human&lt;/div&gt;\n &lt;div class=&quot;content&quot;&gt;so, how was your day&lt;/div&gt;\n &lt;/div&gt; &lt;div class=&quot;message assistant&quot;&gt;\n &lt;div class=&quot;role&quot;&gt;Claude&lt;/div&gt;\n &lt;div class=&quot;content&quot;&gt;I aim to have authentic conversations while being direct about my nature as an AI. While I appreciate the friendly question, I should note that I don&#x27;t actually experience days in the way humans do. I&#x27;d be happy to hear about your day though, or to help you with any questions or tasks you might have.&lt;/div&gt;\n &lt;/div&gt; &lt;/body&gt;\n, {\n headers: {\n \"Content-Type\": \"text/html\",\n },\n });\n }What is the issue with this?</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">Let me help you fix this code. There are a few syntax issues with the current implementation.\nFixed Next.js API HandlerClick to open code\nThe main issues with the original code were:\n\nThe HTML string was not properly formatted - it was directly inserted after the Response( without being enclosed in quotes or backticks\nHTML entities were escaped (&lt;, &gt;, &quot;) when they should have been regular characters (<, >, \")\nNo proper string formatting was used (should use template literals with backticks for multiline strings in JavaScript)\n\nThe fixed version:\n\nUses a template literal (backticks) to properly contain the multiline HTML string\nUses proper HTML syntax without escaped entities\nProperly separates the HTML string from the Response constructor\nMaintains proper indentation for readability\nKeeps the same functionality but in a syntactically correct way\n\nThis should now work correctly as a Next.js API route handler that returns an HTML page.</div>\n </div>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">obj = {\"success\":true,\"val\":{\"id\":\"ab43fa1c-9f05-11ef-ba42-de64eea55b61\",\"author\":{\"id\":\"a15e59cc-3d10-47ad-9065-d19718204f1b\",\"username\":\"adagradschool\"},\"name\":\"claude_d482d9ee_eff3_42e6_9779_a012b1e1f7b4\",\"type\":\"http\",\"code\":\"\\n export default function handler(req) {\\n return new Response(\\\"\\\\n <!DOCTYPE html>\\\\n <html>\\\\n <head>\\\\n <title>Claude Chat Conversation</title>\\\\n <meta charset=\\\\\\\"UTF-8\\\\\\\">\\\\n <style>\\\\n body {\\\\n font-family: system-ui, -apple-system, sans-serif;\\\\n line-height: 1.5;\\\\n max-width: 800px;\\\\n margin: 0 auto;\\\\n padding: 20px;\\\\n background: #f9fafb;\\\\n }\\\\n .message {\\\\n margin: 20px 0;\\\\n padding: 15px;\\\\n border-radius: 8px;\\\\n }\\\\n .human {\\\\n background: #e5e7eb;\\\\n }\\\\n .assistant {\\\\n background: #dbeafe;\\\\n }\\\\n .role {\\\\n font-weight: bold;\\\\n margin-bottom: 8px;\\\\n }\\\\n </style>\\\\n </head>\\\\n <body>\\\\n \\\\n <div class=\\\\\\\"message human\\\\\\\">\\\\n <div class=\\\\\\\"role\\\\\\\">Human</div>\\\\n <div class=\\\\\\\"content\\\\\\\">so, how was your day</div>\\\\n </div>\\\\n \\\\n <div class=\\\\\\\"message assistant\\\\\\\">\\\\n <div class=\\\\\\\"role\\\\\\\">Claude</div>\\\\n <div class=\\\\\\\"content\\\\\\\">I aim to have authentic conversations while being direct about my nature as an AI. While I appreciate the friendly question, I should note that I don't actually experience days in the way humans do. I'd be happy to hear about your day though, or to help you with any questions or tasks you might have.</div>\\\\n </div>\\\\n \\\\n </body>\\\\n\\\", {\\n headers: {\\n \\\"Content-Type\\\": \\\"text/html\\\",\\n },\\n });\\n }\\n \",\"privacy\":\"public\",\"public\":true,\"version\":0,\"createdAt\":\"2024-11-10T01:46:56.862Z\",\"readme\":null,\"likeCount\":0,\"referenceCount\":0,\"url\":\"https://www.val.town/v/adagradschool/claude_d482d9ee_eff3_42e6_9779_a012b1e1f7b4\",\"links\":{\"self\":\"https://api.val.town/v1/vals/ab43fa1c-9f05-11ef-ba42-de64eea55b61\",\"versions\":\"https://api.val.town/v1/vals/ab43fa1c-9f05-11ef-ba42-de64eea55b61/versions\",\"module\":\"https://esm.town/v/adagradschool/claude_d482d9ee_eff3_42e6_9779_a012b1e1f7b4?v=0\",\"endpoint\":\"https://adagradschool-claude_d482d9ee_eff3_42e6_9779_a012b1e1f7b4.web.val.run\"}}}Get val's endpoint</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">Looking at the JSON object, the endpoint URL can be found at obj.val.links.endpoint, which is:\nhttps://adagradschool-claude_d482d9ee_eff3_42e6_9779_a012b1e1f7b4.web.val.run</div>\n </div>\n \n </body>\n </html>\n"`, {
4 headers: {
5 "Content-Type": "text/html",

softTanSlugmain.tsx1 match

@adagradschool•Updated 5 months ago
1
2 export default function handler(req) {
3 return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n </style>\n </head>\n <body>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">so, how was your day</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">I aim to have authentic conversations while being direct about my nature as an AI. While I appreciate the friendly question, I should note that I don't actually experience days in the way humans do. I'd be happy to hear about your day though, or to help you with any questions or tasks you might have.</div>\n </div>\n \n </body>\n"`, {
4 headers: {

stirringCoffeeDonkeymain.tsx1 match

@adagradschool•Updated 5 months ago
1
2 export default function handler(req) {
3 return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n </style>\n </head>\n <body>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">so, how was your day</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">I aim to have authentic conversations while being direct about my nature as an AI. While I appreciate the friendly question, I should note that I don't actually experience days in the way humans do. I'd be happy to hear about your day though, or to help you with any questions or tasks you might have.</div>\n </div>\n \n </body>\n"`, {
4 headers: {
1
2 export default function handler(req) {
3 return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n </style>\n </head>\n <body>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">so, how was your day</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">I aim to have authentic conversations while being direct about my nature as an AI. While I appreciate the friendly question, I should note that I don't actually experience days in the way humans do. I'd be happy to hear about your day though, or to help you with any questions or tasks you might have.</div>\n </div>\n \n </body>\n"`, {
4 headers: {

claudemain.tsx1 match

@adagradschool•Updated 5 months ago
1export default function handler(req) {
2 // The HTML string needs to be properly escaped and formatted as a template literal
3 const html = `<!DOCTYPE html>

claude_share_htmlmain.tsx1 match

@adagradschool•Updated 5 months ago
1export default function handler(req) {
2 return new Response(
3 "\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n </style>\n </head>\n <body>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">so, how was your day</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">I aim to have authentic conversations while being direct about my nature as an AI. While I appreciate the friendly question, I should note that I don't actually experience days in the way humans do. I'd be happy to hear about your day though, or to help you with any questions or tasks you might have.</div>\n </div>\n \n </body>\n",

forwardermain.tsx1 match

@milesfalk•Updated 5 months ago
5const { author, name } = extractValInfo(import.meta.url);
6
7export async function forwarder(e: Email) {
8 let attachments: AttachmentData[] = [];
9 for (const f of e.attachments) {

uptimemain.tsx1 match

@bootspoon•Updated 5 months ago
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;

imageToAnsimain.tsx1 match

@g•Updated 5 months ago
28import { Chalk, type Options as ChalkOptions } from 'npm:chalk';
29
30export async function imageToAnsi(
31 src: string | Image,
32 opts?: Partial<

codecommentermain.tsx2 matches

@JamesAndrew•Updated 5 months ago
15);
16
17function App() {
18 const [input, setInput] = useState("");
19 const [output, setOutput] = useState("");
85}
86
87export default async function server(request: Request): Promise<Response> {
88 if (request.method === "POST" && new URL(request.url).pathname === "/comment") {
89 const { OpenAI } = await import("https://esm.town/v/std/openai");

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",