Search
adventurousApricotGopher
@deffgod
@jsxImportSource https://esm.sh/react
HTTP
completed: false
function VideoPlayer({ course }: { course: Course }) {
const [currentVideo, setCurrentVideo] = useState<CourseVideo | null>(null);
</div>
function CourseCatalog() {
const [selectedCourse, setSelectedCourse] = useState<Course | null>(null);
</div>
function App() {
return <CourseCatalog />;
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
nationstatesSentimentAI
@bohaska
Automatically answers issues from NationStates using AI sentiment analysis, for free! Requires: Huggingface token (HF_TOKEN) for the sentiment analysis of options. Generate a read-only token at Huggingface after making an account to use. Email address (EMAIL) for user agent. Required as per NationStates ToS Autologin token (AUTOLOGIN) for logging into NationStates. See NationStates API docs for more info. Nation name (NATION_ID). Put your nation name, the one you use when you login to your account. Selects the option with the highest positivity score. Feel free to adapt the algorithm to your own tastes. See the Republic of Positivum for an example of this val in action.
Cron
const option_regex = /<OPTION id="(\d+)">(.*?)<\/OPTION>\s*/g;
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
async function query(data) {
const response = await fetch(
return result;
export default async function(interval: Interval) {
const httpHeaders = {
![stevekrouse avatar](https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg)
steel_puppeteer_starter
@stevekrouse
Steel + Puppeteer Starter This template shows you how to use Steel with Puppeteer
to run browser automations in the cloud on Val Town.
It includes session management, error handling,
and a basic example you can customize. This starter
templated was ported from
this one on Github . Quick start The script shows you how to: Create and manage a Steel browser session Connect Puppeteer to the session Navigate to a website (Hacker News in this example) Extract data from the page (top 5 stories) Handle errors and cleanup properly View your live session in Steel's session viewer To run it: Get your free Steel API key at https://app.steel.dev/settings/api-keys Add it to your Val Town Environment Variables as STEEL_API_KEY Click Fork on this val Click Run on this val Writing your automation Find this section in the script: // ============================================================
// Your Automations Go Here!
// ============================================================
// Example automation (you can delete this)
await page.goto('https://news.ycombinator.com');
// ... rest of example code You can replace the code here with whatever automation scripts you want to run. Configuration The template includes common Steel configurations you can enable: const session = await client.sessions.create({
useProxy: true, // Use Steel's proxy network
solveCaptcha: true, // Enable CAPTCHA solving
sessionTimeout: 1800000, // 30 minute timeout (default: 15 mins)
userAgent: 'custom-ua', // Custom User-Agent
}); Error handling The template includes error handling and cleanup: try {
// Your automation code
} finally {
// Cleanup runs even if there's an error
if (browser) await browser.close();
if (session) await client.sessions.release(session.id);
} Support Steel Documentation API Reference Discord Community
Script
const client = new Steel({
steelAPIKey: STEEL_API_KEY,
async function main() {
let session;
let browser;
valle_tmp_912892474311848739315304600970236
@janpaul123
// This val responds with "Hello, World!" to all incoming HTTP requests.
HTTP
// This val responds with "Hello, World!" to all incoming HTTP requests.
export default async function main(req: Request): Promise<Response> {
return new Response("Hello, World!");
getTeams
@brianleroux
An interactive, runnable TypeScript val by brianleroux
Script
import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
export default async function getTeams() {
let url = "https://www.capfriendly.com";
let res = await fetch(url);
![hite avatar](https://images.clerk.dev/oauth_github/img_2RS0wW6gwHqcuibUwrLg95NJONL.jpeg)
myApi
@hite
An interactive, runnable TypeScript val by hite
Script
export function myApi(name) {
return "hi " + name;
val_9Vk5LnFz7t
@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) {
endpointCalculator
@ejfox
* This program creates a basic calculator endpoint that accepts and returns data in the specified format.
* It uses a RESTful API approach where the operation is specified in the URL path.
* The numbers to operate on are passed as query parameters.
* The result is returned as JSON.
HTTP
* The result is returned as JSON.
export default async function server(request: Request): Promise<Response> {
const url = new URL(request.url);
headers: { 'Content-Type': 'application/json' }
function add(numbers: number[]): number {
return numbers.reduce((a, b) => a + b, 0);
function subtract(numbers: number[]): number {
return numbers.reduce((a, b) => a - b);
function multiply(numbers: number[]): number {
return numbers.reduce((a, b) => a * b, 1);
function divide(numbers: number[]): number {
if (numbers.includes(0)) {
return numbers.reduce((a, b) => a / b);
function pow(numbers: number[]): number {
return numbers.reduce((a, b) => Math.pow(a, b));
function sqrt(number: number): number {
if (number < 0) {
return Math.sqrt(number);
function log(number: number): number {
if (number <= 0) {
highlightExample
@just_be
Highlight Example This is an example of my highlight val.
HTTP
export default async function(req: Request): Promise<Response> {
const { searchParams } = new URL(req.url);
const code = await searchParams.get("code") ?? "let builder = WebViewBuilder::new(&window);";
crimsonNewt
@shivanirajan
// Fetches a random joke.
Script
// ... imports ...
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
val_070RHpl6iO
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_070RHpl6iO(req) {
try {
// Execute the code directly and capture its result
AICodeGeneratorApp
@mrshorts
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
function AppCraftAI() {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
conceptCompletion = await openai.chat.completions.create({
codeCompletion = await openai.chat.completions.create({
} catch (openaiError) {
console.error('OpenAI generation error:', openaiError);
function App() {
<p>Basic app structure with placeholder functionality</p>
{ type: 'Functionality', passed: Math.random() > 0.2 },
![jonbo avatar](https://images.clerk.dev/oauth_github/img_2TPc6zoaCKXU8JPkSZY3yWTXnA4.jpeg)
lableaks
@jonbo
An interactive, runnable TypeScript val by jonbo
HTTP
export async function lableaks(request: Request): Promise<Response> {
document.addEventListener("DOMContentLoaded", function () {
ws.onopen = function () {
ws.onmessage = function (event) {
function sendChoice(choice) {
// setTimeout(function () {
buttonA.addEventListener("click", function () {
buttonB.addEventListener("click", function () {
ws.onclose = function () {
ws.onerror = function (error) {