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=1119&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 18002 results for "function"(2065ms)

clearMagentaFlyingfishmain.tsx1 match

@Amr0111•Updated 3 months ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

imageUploadPerMinuteWebsitemain.tsx7 matches

@Chishti78studi•Updated 3 months ago
4
5// Main React component for the image upload application
6function App() {
7 // State variables to manage images, error messages, upload restrictions, and comments
8 const [images, setImages] = useState([]); // Stores uploaded images
37 }, [currentPage]);
38
39 // Function to retrieve images from the server with pagination
40 const fetchImages = async () => {
41 try {
50 };
51
52 // Function to retrieve comments from the server
53 const fetchComments = async () => {
54 try {
85 };
86
87 // Bulk upload function
88 const handleBulkUpload = async () => {
89 if (!isUsernameSet) {
265}
266
267// Server-side modifications in handler functions
268
269async function handleUpload(request, sqlite, KEY, TABLE_VERSION) {
270 const formData = await request.formData();
271 const image = formData.get('image') as File;
292}
293
294async function handleGetImages(sqlite, KEY, TABLE_VERSION, page = 1, pageSize = 100) {
295 const offset = (page - 1) * pageSize;
296

jarvisPrototypemain.tsx3 matches

@pashaabhi•Updated 3 months ago
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [conversation, setConversation] = useState<{ role: string; content: string }[]>([]);
7 const recognitionRef = useRef<any>(null);
236}
237
238function client() {
239 createRoot(document.getElementById("root")).render(<App />);
240}
241if (typeof document !== "undefined") { client(); }
242
243export default async function server(request: Request): Promise<Response> {
244 if (request.method === "POST") {
245 const { OpenAI } = await import("https://esm.town/v/std/openai");

homeControlDevicemain.tsx3 matches

@Vikramhaking•Updated 3 months ago
11};
12
13function HomeControlApp() {
14 const [devices, setDevices] = useState<DeviceState[]>([
15 { id: '1', name: 'Living Room Light', type: 'light', isOn: false },
101}
102
103function client() {
104 createRoot(document.getElementById("root")).render(<HomeControlApp />);
105}
106if (typeof document !== "undefined") { client(); }
107
108export default async function server(request: Request): Promise<Response> {
109 return new Response(`
110 <html>

OpenRouterChatCompletionmain.tsx1 match

@rozek•Updated 3 months ago
4/**** free, but rate-limited access to the OpenRouter API ****/
5
6 export default async function (Request:Request):Promise<Response> {
7 if (Request.method === 'OPTIONS') {
8 return new Response(null, {

OpenRouter_Testmain.tsx1 match

@rozek•Updated 3 months ago
5const Granularity = 15*60*1000
6
7export default async function (Request:Request):Promise<Response> {
8 if (Request.method !== 'GET') {
9 return new Response('Method Not Allowed', { status:405 })

OpenRouterChatCompletionLeadmain.tsx1 match

@rozek•Updated 3 months ago
4/**** how long until "OpenAIChatCompletion" becomes available again? ****/
5
6 export default async function (Request:Request):Promise<Response> {
7 if (Request.method === 'OPTIONS') {
8 return new Response(null, {

lastloginmain.tsx4 matches

@AIWB•Updated 3 months ago
1/** @jsxImportSource npm:hono/jsx */
2async function createSession(email: string, hostname: string) {
3 const { zip } = await import("https://esm.town/v/pomdtr/sql");
4 const { sqlite } = await import("https://esm.town/v/std/sqlite");
23}
24
25async function getSession(sessionID: string, hostname: string) {
26 const { zip } = await import("https://esm.town/v/pomdtr/sql");
27 const { sqlite } = await import("https://esm.town/v/std/sqlite");
52}
53
54async function deleteSession(sessionID: string) {
55 const { sqlite } = await import("https://esm.town/v/std/sqlite");
56
64const OAUTH_COOKIE = "oauth_store";
65
66export function lastlogin(
67 handler: (req: Request) => Response | Promise<Response>,
68) {

growingAquamarineFleamain.tsx10 matches

@SowrovCIV•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function Header() {
6 return (
7 <header className="bg-blue-500 text-white p-4 shadow-md">
20}
21
22function MainBanner() {
23 const [videoLink, setVideoLink] = useState('');
24
63}
64
65function FeaturesSection() {
66 const features = [
67 {
110}
111
112function HowItWorksSection() {
113 return (
114 <section className="bg-gray-100 p-8 rounded-lg shadow-md">
135}
136
137function FAQSection() {
138 const [activeIndex, setActiveIndex] = useState(null);
139
187}
188
189function ContactSection() {
190 const socialLinks = [
191 {
249}
250
251function Footer() {
252 return (
253 <footer className="bg-blue-500 text-white py-6">
278}
279
280function App() {
281 return (
282 <div className="flex flex-col min-h-screen">
296}
297
298function client() {
299 createRoot(document.getElementById("root")).render(<App />);
300}
301if (typeof document !== "undefined") { client(); }
302
303export default async function server(request: Request): Promise<Response> {
304 return new Response(`
305 <html>

tikTokVideoDownloadermain.tsx3 matches

@SowrovCIV•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [videoUrl, setVideoUrl] = useState('');
7 const [downloadLink, setDownloadLink] = useState('');
224};
225
226function client() {
227 createRoot(document.getElementById("root")).render(<App />);
228}
229if (typeof document !== "undefined") { client(); }
230
231export default async function server(request: Request): Promise<Response> {
232 return new Response(`
233 <html>

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": "*",