Search
myApi
@mss
An interactive, runnable TypeScript val by mss
Script
export function myApi(name) {
console.email("hello " + name);
return "hello " + name;
myApi
@wonday
An interactive, runnable TypeScript val by wonday
Script
import { name as name2 } from "https://esm.town/v/wonday/name";
export function myApi(name) {
return `hi ${name}! my name is ${name2}`;
generatehaikuwebsite
@gueejla
Townie created an excellent haiku generator page
HTTP
import React, { useState } from "https://esm.sh/react@18.2.0";
function App() {
const [topic, setTopic] = useState("");
fontStyle: "italic",
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
if (request.method === "POST" && request.url.includes("/generate")) {
const { topic } = await request.json();
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
myApi
@sarincasm
An interactive, runnable TypeScript val by sarincasm
Script
export function myApi(name) {
return "hi " + name;
servicefactory
@dglazkov
A helper to create an HTTP endpoint that conforms to the Breadboard Service Endpoint (BSE) protocol. See https://www.val.town/v/dglazkov/googlenews for sample usage. For more information, see Breadboard service node .
Script
examples?: string[];
export type InvokeFunction = (inputs: InputValues) => Promise<OutputValues>;
export type DescribeFunction = (
inputs?: InputValues,
export const service = (
describe: DescribeFunction,
invoke: InvokeFunction,
options?: ServiceOptions,
return async function(req: Request): Promise<Response> {
const url = new URL(req.url);
ListenTo
@zzz
// https://api.val.town/v1/express/zzz.ListenTo?val=stevekrouse.whatIsValTown
Script
import { runVal } from "https://esm.town/v/std/runVal";
// https://api.val.town/v1/express/zzz.ListenTo?val=stevekrouse.whatIsValTown
export async function ListenTo(req, res) {
const { val = "zzz.demoOpenAIGPT4Summary" } = req.query;
const url = `https://api.val.town/v1/run/${val.replace("@", "")}`
const resp = await fetch(url);
myApi
@nathanpower
An interactive, runnable TypeScript val by nathanpower
Script
export function myApi(name) {
return "hi " + name;
valle_tmp_605448986086057210791953389018616
@janpaul123
@jsxImportSource https://esm.sh/react
HTTP
import OpenAI from "npm:openai";
unless strictly necessary, for example use APIs that don't require a key, prefer internal function
functions where possible. Unless specified, don't add error handling,
The val should create a "export default async function main" which is the main function that gets
// The val should create a "export default async function main() {" which
// is the main function that gets executed, without any arguments. Don't return a Response object,
function write(text) {
const callback = function (mutationsList, observer) {
function updateValName(valName) {
function saveVal() {
GROKPROMPT
@AppleLamps
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
function App() {
function client() {
* It uses OpenAI API to generate detailed and concise prompts.
export default async function server(request: Request): Promise<Response> {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
console.log("Sending request to OpenAI:", JSON.stringify(analysisMessages, null, 2));
const completion = await openai.chat.completions.create({
console.log("Received response from OpenAI:", JSON.stringify(completion, null, 2));
console.error("Error in server function:", error);
weatherGPT
@serkanokur
Cron
import { email } from "https://esm.town/v/std/email?v=11";
import { OpenAI } from "npm:openai";
let location = "munchen";
).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 });
val_NGfT1TNGLh
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_NGfT1TNGLh(req) {
try {
// Execute the code directly and capture its result
myApi
@taowen
An interactive, runnable TypeScript val by taowen
Script
export function myApi(name) {
return "hi " + name;
auth
@brianleroux
An interactive, runnable TypeScript val by brianleroux
Script
import { getSignedCookie, setSignedCookie } from "npm:hono/cookie";
export async function login(c) {
const body = await c.req.formData();
await setSignedCookie(c, "loggedIn", loggedIn + "", Deno.env.get("SECRET"));
export async function logout(c) {
await setSignedCookie(c, "loggedIn", "false", Deno.env.get("SECRET"));
export async function isLoggedIn(c) {
const { loggedIn } = await getSignedCookie(c, Deno.env.get("SECRET"));
val_wKbtsxNAcg
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_wKbtsxNAcg(req) {
try {
// Execute the code directly and capture its result
duckdbExample
@neverstew
An interactive, runnable TypeScript val by neverstew
Script
import { fetch } from "https://esm.town/v/std/fetch";
export let duckdbExample = (async () => {
async function createWorker(url: string) {
const workerScript = await fetch(url);
const workerURL = URL.createObjectURL(await workerScript.blob());