Search

Results include substring matches and semantically similar vals. Learn more
blaiselp avatar
myApi
@blaiselp
An interactive, runnable TypeScript val by blaiselp
Cron
export function myApi(name) {
return "hi " + name;
dhvanil avatar
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
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") {
janpaul123 avatar
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");
iamseeley avatar
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, "&#039;");
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;
awhitter avatar
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 }],
elrey741 avatar
myApi
@elrey741
An interactive, runnable TypeScript val by elrey741
Script
export function myApi(name) {
return "hi " + name;
minhee avatar
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 === "/") {
dhvanil avatar
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 });
bikefixe avatar
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
myApi
@zzz
An interactive, runnable TypeScript val by zzz
Script
export function myApi(name) {
name = name || "Guest";
return `Hello, ${name}`;
darcy avatar
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
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;
janpaul123 avatar
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
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,
ults to "google-perspective-api" (Google's Perspective API); it can also be "openai" (OpenAI Moderation API) or "google-natur
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();
…
86
…
Next