Search
myApi
@blaiselp
An interactive, runnable TypeScript val by blaiselp
Cron
export function myApi(name) {
return "hi " + name;
web_9t1xAJu6Te
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_9t1xAJu6Te(req) {
return new Response(`<!DOCTYPE html>
<html>
![saolsen avatar](https://images.clerk.dev/oauth_github/img_2QtXHzN3gDPhKsBOvKsst8LTxC5.png)
gameplay_agent
@saolsen
gameplay_agent This is a val.town mirror of gameplay/games/agent . Click the link to see docs.
Script
agentname: string;
/** The agent function. */
agent: Connect4Agent<T> | Connect4AsyncAgent<T>;
agentname: string;
/** The agent function. */
agent: PokerAgent<T> | PokerAsyncAgent<T>;
* a variety of different http server libraries.
* To see how to write the agent functions,
* see the {@link Connect4Agent} and {@link PokerAgent}
* used with an http server that supports the fetch interface.
export function agentHandler<
T extends Json = Json,
): (req: Request) => Promise<Response> {
return async function(request: Request): Promise<Response> {
if (request.method === "GET") {
valle_tmp_77183865308193063054442024667199
@janpaul123
// This val simply responds to all HTTP requests with "Hello world"
HTTP
// This val simply responds to all HTTP requests with "Hello world"
export default async function main(req: Request): Promise<Response> {
return new Response("Hello world");
valPreview
@iamseeley
// Ensure the handler functions are accessible globally
Script
export async function fetchVal(valId: string) {
try {
return null;
export async function evalCode(code: string) {
try {
return { error: 'Network error: Unable to evaluate code' };
function handleEvalCode(elementId: string) {
const element = document.getElementById(`code-${elementId}`);
console.error('Could not find code element');
export async function previewVal(valName: string, resultElementId: string) {
try {
resultElement.innerHTML = `<pre class="error">${error.message}</pre>`;
function escapeHtml(unsafe: string) {
return unsafe
.replace(/'/g, "'");
export function injectValContent(valId: string, elementId: string) {
return fetchVal(valId).then(data => {
console.error(`Element with ID ${elementId} not found.`);
export function initializeValComponents() {
document.querySelectorAll('[data-val-id]').forEach(element => {
Prism.highlightAll();
function handlePreviewVal(elementId: string, valName: string) {
const previewElementId = `preview-${elementId}`;
resultElement.innerHTML = `<pre class="error">Error: ${error.message}</pre>`;
// Ensure the handler functions are accessible globally
(window as any).handlePreviewVal = handlePreviewVal;
competentOlivePeacock
@awhitter
ok
HTTP
Video?: AirtableAttachment[];
function ContentTemplateApp() {
const [content, setContent] = useState<AirtableRecord[]>([]);
</div>
function client() {
createRoot(document.getElementById("root")).render(<ContentTemplateApp />);
client();
export default async function server(req: Request): Promise<Response> {
const url = new URL(req.url);
if (req.method === "POST") {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
try {
Full Content: ${fullContent}`;
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],
myApi
@elrey741
An interactive, runnable TypeScript val by elrey741
Script
export function myApi(name) {
return "hi " + name;
FedifyOnValTown
@minhee
Fedify on Val Town This is a single file implementation of ActivityPub using Fedify on Val Town . If you follow @demo@minhee-fedifyonvaltown.web.val.run on your fediverse account,
it will follow you back. Thanks to Fedify & Val Town, it only consists of a single TypeScript file with
about 170 lines.
HTTP
to: follower.id,
object: follower.id,
export default async function (req: Request): Promise<Response> {
const url = new URL(req.url);
if (url.pathname === "/") {
val_E1oovKNSVp
@dhvanil
An interactive, runnable TypeScript val by dhvanil
Script
export default async function handler(req) {
try {
const result = await (async () => {
function fibonacci() { let a = 0, b = 1; while (b < 1000) { let temp = b; b = a + b; a = temp; } return b;}
fibonacci();
return Response.json({ success: true, result });
TanaPasteExample
@bikefixe
An interactive, runnable TypeScript val by bikefixe
Script
export async function TanaPasteExample(req, res) {
// you call this functioin from Tana's make API request
// as https://api.val.town/express/@bikefixe.TanaPasteExample?arg=stufftopassin
![zzz avatar](https://images.clerk.dev/oauth_github/img_2QtQgqd8dFlYhzY8Y7Sv9CJ881v.jpeg)
myApi
@zzz
An interactive, runnable TypeScript val by zzz
Script
export function myApi(name) {
name = name || "Guest";
return `Hello, ${name}`;
![darcy avatar](https://images.clerk.dev/oauth_github/img_2SRoU48QlR5vYMeKLjnBC3rs2LY.jpeg)
feed
@darcy
An interactive, runnable TypeScript val by darcy
Cron
import { following } from "https://esm.town/v/darcy/following";
import { fetch } from "https://esm.town/v/std/fetch";
export function feed() {
let _feed = following.map(async (name) => {
let req = await fetch(`https://api.val.town/v1/run/${name}.posts`);
![neverstew avatar](https://secure.gravatar.com/avatar/109fa713caf4e083c57622b7c6dad365.jpg?s=200&d=identicon)
val
@neverstew
An interactive, runnable TypeScript val by neverstew
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export function val({ token, id }: {
token?: string;
id: string;
valle_tmp_290532195688157024602543648883546
@janpaul123
// We will create an HTTP val that responds with "Hello world" on every request.
HTTP
// We will create an HTTP val that responds with "Hello world" on every request.
// We will use Deno's built-in HTTP module to create the server and handle incoming requests.
// Define the main function that will handle HTTP requests
export default async function main(_req: Request) {
// Return a simple Response with "Hello world"
return new Response("Hello world");
![stevekrouse avatar](https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg)
tanLadybug
@stevekrouse
content-checker is designed to be a modern, open-source library for programmatic and AI content moderation. Currently content-checker supports image and text moderation.
Thanks to LLMs in addition to detecting specific profane words, we can detect malicious intent in text.
So, a user who tries to circumvent the AI profanity filter by using a variation of a profane word, or even just a malicious phrase
without a specific word in the profanity list, will still be flagged. Image moderation is also supported, using the Inception V3 model of the NSFW JS library. Future features will include moderation tools (auto-ban, bots), more powerful models, and multimedia support for video and audio moderation. To get an API key for the AI endpoints sign up free at https://www.openmoderator.com
To install content-checker do npm install content-checker and check out the README: https://github.com/utilityfueled/content-checker
HTTP
dangerouslySetInnerHTML={{
__html: `document.addEventListener('DOMContentLoaded', function() {
const form = document.querySelector('form');
form.addEventListener('submit', async function(event) {
event.preventDefault();
newScript.innerHTML = \`
document.addEventListener('DOMContentLoaded', function() {
const form = document.querySelector('form');
form.addEventListener('submit', async function(event) {
event.preventDefault();
checkManualProfanityList: false,
// provider defaults to "google-perspective-api" (Google's Perspective API); it can also be "openai" (OpenAI Moderation API) or "google-natural-language-api" (Google's Natural Language API)
provider: "google-perspective-api",
dangerouslySetInnerHTML={{
__html: `document.addEventListener('DOMContentLoaded', function() {
const form = document.querySelector('form');
form.addEventListener('submit', async function(event) {
event.preventDefault();
newScript.innerHTML = \`
document.addEventListener('DOMContentLoaded', function() {
const form = document.querySelector('form');
form.addEventListener('submit', async function(event) {
event.preventDefault();