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=1090&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 17289 results for "function"(2138ms)

weathermain.tsx5 matches

@gao•Updated 3 months ago
15};
16
17function HourlyWeather({ hourlyData }) {
18 return (
19 <div style={{
47}
48
49function WeatherApp() {
50 const [weatherData, setWeatherData] = useState(null);
51 const [loading, setLoading] = useState(true);
52
53 useEffect(() => {
54 async function fetchWeather() {
55 try {
56 const response = await fetch(
148}
149
150function client() {
151 createRoot(document.getElementById("root")).render(<WeatherApp />);
152}
153if (typeof document !== "undefined") { client(); }
154
155export default async function server(request: Request): Promise<Response> {
156 return new Response(`
157 <html>

competentCoffeeTyrannosaurusmain.tsx4 matches

@shivammunday•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function WebsiteChatbot() {
6 const [messages, setMessages] = useState([
7 { role: 'assistant', content: 'Hello! I am your personal website assistant. How can I help you today?' }
10 const [isLoading, setIsLoading] = useState(false);
11
12 async function handleSubmit(e: React.FormEvent) {
13 e.preventDefault();
14 if (!input.trim()) return;
67}
68
69function client() {
70 const chatbotRoot = document.createElement('div');
71 chatbotRoot.id = 'website-chatbot-root';
76if (typeof document !== 'undefined') { client(); }
77
78export default async function server(request: Request) {
79 if (request.method === 'POST' && new URL(request.url).pathname === '/chat') {
80 const { OpenAI } = await import("https://esm.town/v/std/openai");

cerebras_codermain.tsx11 matches

@tonyStark•Updated 3 months ago
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
170 });
171
172 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173 setLoading(true);
174 setTimeout(() => handleSubmit(promptItem.prompt), 0);
175 }
176
177 async function handleSubmit(e: React.FormEvent | string) {
178 if (typeof e !== "string") {
179 e.preventDefault();
226 }
227
228 function handleVersionChange(direction: "back" | "forward") {
229 const { currentVersionIndex, versions } = versionHistory;
230 if (direction === "back" && currentVersionIndex > 0) {
974);
975
976function client() {
977 const path = window.location.pathname;
978 const root = createRoot(document.getElementById("root")!);
1010}
1011
1012function extractCodeFromFence(text: string): string {
1013 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014 return htmlMatch ? htmlMatch[1].trim() : text;
1015}
1016
1017async function generateCode(prompt: string, currentCode: string) {
1018 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019 if (starterPrompt) {
1060}
1061
1062export default async function cerebras_coder(req: Request): Promise<Response> {
1063 // Dynamic import for SQLite to avoid client-side import
1064 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163 <meta property="og:site_name" content="Cerebras Coder">
1164 <meta property="og:url" content="https://cerebrascoder.com"/>
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">

KPoolCafeGameMenumain.tsx3 matches

@Kpool•Updated 3 months ago
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [selectedCategory, setSelectedCategory] = useState("cafe");
7 const [playerName, setPlayerName] = useState("");
394};
395
396function client() {
397 createRoot(document.getElementById("root")).render(<App />);
398}
399if (typeof document !== "undefined") { client(); }
400
401export default async function server(request: Request): Promise<Response> {
402 // Server-side code remains the same as in the previous implementation
403 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");

astuteYellowDeermain.tsx12 matches

@vesty91•Updated 3 months ago
57
58// Service page components (unchanged)
59function DiagnosticGratuitPage() {
60 return (
61 <div className="service-page">
81}
82
83function NettoyageOptimisationPage() {
84 return (
85 <div className="service-page">
107}
108
109function ReparationMateriellePage() {
110 return (
111 <div className="service-page">
132}
133
134function SauvegardeRecuperationPage() {
135 return (
136 <div className="service-page">
156}
157
158function InstallationLogiciellePage() {
159 return (
160 <div className="service-page">
186}
187
188function SupportDistancePage() {
189 return (
190 <div className="service-page">
210}
211
212function TarifSystemesExploitationPage() {
213 return (
214 <div className="service-page">
301}
302
303function HomePage() {
304 const [showWelcome, setShowWelcome] = useState(true);
305 const [services, setServices] = useState([
362}
363
364function App() {
365 const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
366 const [activeDropdown, setActiveDropdown] = useState<string | null>(null);
452}
453
454function client() {
455 createRoot(document.getElementById("root")).render(<App />);
456}
457if (typeof document !== "undefined") { client(); }
458
459export default async function server(request: Request): Promise<Response> {
460 return new Response(`
461 <html>
479}
480
481function getCss() {
482 return `
483 * {

criticEmailmain.tsx2 matches

@paulkinlan•Updated 3 months ago
5import { OpenAI } from "npm:openai";
6
7function stripHtmlBackticks(html: string): string {
8 return html.replace(/^```html\n?/, "").replace(/\n?```$/, "");
9}
10
11export default async function(e: Email) {
12 const openai = new OpenAI();
13 console.log(`from: ${e.from} to: ${e.to} subject: ${e.subject}, cc: ${e.cc}, bcc: ${e.bcc}`);

SKHomesTenantManagementmain.tsx2 matches

@skhomes•Updated 3 months ago
5// [Previous code remains unchanged]
6
7export default async function server(request: Request): Promise<Response> {
8 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
9 const KEY = "SKHomesTenantManagement";
10 const SCHEMA_VERSION = 3;
11
12 // CSS definition moved inside the server function
13 const css = `
14 body {

LifeLogFitbitAuthorizemain.tsx1 match

@snowypowers•Updated 3 months ago
9 * Visit this url to get authorized for lifelog to collect data.
10 */
11export default async function(req: Request): Promise<Response> {
12 console.log(`verifier: ${verifier}`);
13 blob.set(`fibit_state_${state}`, verifier);
15
16// Wallet Connection Hook
17function usePhantomWallet() {
18 const [wallet, setWallet] = useState(null);
19 const [connected, setConnected] = useState(false);
47
48// Main Application Component
49function TokenBoostApp() {
50 const { wallet, connected, connectWallet, disconnectWallet } = usePhantomWallet();
51 const [boostAmount, setBoostAmount] = useState(100);
201
202// Client-side rendering
203function client() {
204 createRoot(document.getElementById("root")).render(<TokenBoostApp />);
205}
208
209// Server-side handler
210export default async function server(request: Request): Promise<Response> {
211 if (request.method === 'POST') {
212 const body = await request.json();

spontaneousAmaranthFinchmain.tsx1 match

@mattrw2•Updated 3 months ago
4const datePattern = /\b[A-Za-z]{3}\s\d{1,2}\b/;
5
6export default async function(interval: Interval) {
7 const response = await fetch("https://www.sperrychalet.com/vacancy_s.html");
8 const body = await response.text();

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