Search
![pomdtr avatar](https://images.clerk.dev/oauth_github/img_2RCoAITJZH1QencEgtVjh4Qirj4.jpeg)
fetchAPI
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
import { API_URL } from "https://esm.town/v/std/API_URL";
export async function fetchAPI(
path: string,
options?: RequestInit & {
![carsonwack avatar](https://images.clerk.dev/oauth_github/img_2SloQgO8GhORZkrV12U8dU4Iy7U.jpeg)
myApi
@carsonwack
An interactive, runnable TypeScript val by carsonwack
Script
export function myApi(name) {
return "hi " + name;
codemirror_demo
@nbbaier
An interactive, runnable TypeScript val by nbbaier
HTTP
const editor = document.getElementById("editor");
function selectStatementFromPosition(statements, pos) {
for (const statement of statements) {
return undefined;
function getCode() {
const code = editor.code;
</html>
export default reloadOnSaveFetchMiddleware(async function(req: Request): Promise<Response> {
return new Response(body, {
val_PersGjiwTK
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_PersGjiwTK(req) {
try {
// Execute the code directly and capture its result
myApi
@M3RCYAJ
An interactive, runnable TypeScript val by M3RCYAJ
Script
export function myApi(name) {
return "hi " + name;
![seflless avatar](https://secure.gravatar.com/avatar/41340a7f3930b7d87be5949c4e538410.jpg?s=200&d=identicon)
weatherGPT
@seflless
If you fork this, you'll need to set OPENAI_API_KEY in your Val Town Secrets .
HTTP
If you fork this, you'll need to set `OPENAI_API_KEY` in your [Val Town Secrets](https://www.val.town/settings/secrets).
import { html } from "https://esm.town/v/stevekrouse/html?v=5";
export function WeatherSuggest() {
// const onClick = () => alert("Button clicked!");
return !data ? <p>Loading...</p> : <p>{data}</p>;
export default async function weatherGPT(req: Request) {
const { OpenAI } = await import("npm:openai");
if (new URL(req.url).pathname === "/data") {
![stevekrouse avatar](https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg)
browserbase
@stevekrouse
@jsxImportSource npm:hono@3/jsx
HTTP
const app = new Hono();
const browserbase = new Browserbase();
function duration(session) {
const startedAt = new Date(session.startedAt).getTime();
if (session.status === "RUNNING") {
return `${hours}:${String(minutes % 60).padStart(2, "0")}:${String(Math.floor(seconds % 60)).padStart(2, "0")}`;
return `${minutes}:${String(Math.floor(seconds % 60)).padStart(2, "0")}`;
function SessionsTable({ sessions, currentPage }: { sessions: Session[]; currentPage: number }) {
const sessionsPerPage = 10;
const totalPages = Math.ceil(sessions.length / sessionsPerPage);
redScallop
@iamseeley
An interactive, runnable TypeScript val by iamseeley
HTTP
export default async function handler(req: Request): Promise<Response> {
const htmlContent = `
<!DOCTYPE html>
![stevekrouse avatar](https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg)
myApi
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export function myApi(name) {
return "hi " + name;
weatherGPT
@tgrv
Cron
import { email } from "https://esm.town/v/std/email?v=11";
import { OpenAI } from "npm:openai";
let location = "Wolfsburg";
).then(r => r.json());
const openai = new OpenAI();
let chatCompletion = await openai.chat.completions.create({
messages: [{
console.log(text);
export async function weatherGPT() {
await email({ subject: "Weather Today", text });
![usefulthink avatar](https://images.clerk.dev/oauth_github/img_2TLCFQNhV4NrYmJtXuT0qrFJK1f.jpeg)
myApi
@usefulthink
An interactive, runnable TypeScript val by usefulthink
Script
export function myApi(name) {
return "hi " + name;
opensaas
@mmaksimovic
A GitHub webhook handler to capture stars in PostHog
HTTP
import { capturePostHogEvent } from "https://esm.town/v/ianvph/capturePostHogEvent";
export default async function(req: Request): Promise<Response> {
if (req.method !== "POST") {
return Response.json({ ok: "only post request" });
![adin avatar](https://images.clerk.dev/oauth_github/img_2Qu3PLoh54HdoTfQ67L4rz8hIZU.png)
myApi
@adin
An interactive, runnable TypeScript val by adin
Script
export function myApi(name) {
return "hi " + name;
valle_tmp_8524715891926958662818742653551
@janpaul123
// This val will serve an HTML page emulating a Hacker News clone.
HTTP
// It uses plain HTML and CSS to create the frontend. Eventually,
// we can make it interactive with additional scripts.
export default async function(req: Request): Promise<Response> {
const htmlContent = `
<!DOCTYPE html>
legitimateTanTiger
@sharanbabu
* This code creates a search engine prototype with autocomplete functionality using the Cerebras LLM API.
* It uses React for the frontend and the Cerebras API for generating autocomplete suggestions.
* The suggestions are cached in the browser to reduce API calls.
* It implements a two-step LLM process: first to get initial suggestions, then to filter them for sensibility and ethics.
* If the second LLM call fails, it displays "Failed to fetch" instead of showing results.
HTTP
* This code creates a search engine prototype with autocomplete functionality using the Cerebras LLM API.
* It uses React for the frontend and the Cerebras API for generating autocomplete suggestions.
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [query, setQuery] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
async function server(request: Request): Promise<Response> {
if (request.method === "POST" && new URL(request.url).pathname === "/suggestions") {
} catch (error) {
console.error("Error calling Cerebras API:", error);
return new Response(JSON.stringify({ error: "Failed to fetch" }), {