Search

Results include substring matches and semantically similar vals. Learn more
jesi_rgb avatar
email_weather
@jesi_rgb
* This val will create a daily weather email service. * It uses the OpenWeatherMap API to fetch weather data and the Val Town email API to send emails. * The val will be triggered daily using a cron job.
Cron
import { email } from "https://esm.town/v/std/email";
import { OpenAI } from "https://esm.town/v/std/openai";
const OPENWEATHERMAP_API_KEY = Deno.env.get("WEATHER_API_KEY");
const CITY = "CΓ³rdoba, EspaΓ±a"; // Change this to your desired city
async function getWeatherData() {
const response = await fetch(
return await response.json();
async function generateEmailContent(weatherData) {
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
return completion.choices[0].message.content;
async function sendWeatherEmail() {
const weatherData = await getWeatherData();
text: emailContent,
export default async function server(req: Request): Promise<Response> {
if (req.headers.get("User-Agent")?.includes("valtown-cron")) {
pomdtr avatar
tree_example
@pomdtr
View Example View Extension Repository #example
HTTP
url: `https://www.val.town/v/${val.author.username}/${val.name}`,
return c.json(items);
// You can build you own helper function
function linkItem(title: string, url: string): Item {
return {
title,
narraje avatar
aquaLizard
@narraje
// Fetches a random joke.
Cron
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
stevekrouse avatar
discordEventReceiver
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
export default async function handler(req: Request) {
if (req.method !== 'POST') {
return new Response('Method not allowed', { status: 405 });
nelicious avatar
scientificPlumStarfish
@nelicious
Hello!!! Feel free to mess around with this val and make it your own :). Just click on "Fork" in the top right. You can change the phrases that show up as you click no, you can change the firstImg and secondImg, maybe even add more images. And you can also change the colors and any of the text on the screen! Have fun with it and hopefully your crush says yes hehe.
HTTP
"maybe??",
function App() {
const [noClicks, setNoClicks] = useState(0);
</div>
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(
chet avatar
watchNimbusDam
@chet
An interactive, runnable TypeScript val by chet
Cron
import { watchWebsite } from "https://esm.town/v/chet/watchWebsite";
export default async function(interval: Interval) {
await watchWebsite("https://cdec.water.ca.gov/dynamicapp/QueryRES?s=NAT");
maxm avatar
tinygoHttpExample
@maxm
A Go http handler running in Val Town: The Go source is here . Mandelbrot rendering code taken from here . I used maxm/compileAndUploadTinygoWasm to compile the code and create the val. $ git clone git@github.com:maxmcd/go-town.git $ cd go-town/val-town-tinygo-http-example $ deno run --allow-net --allow-run --allow-read "https://esm.town/v/maxm/compileAndUploadTinygoWasm?v=58" Running tinygo build -o main.wasm -target=wasi . Compliation complete Running wasm-strip main.wasm Copy the following into a val town HTTP val: import { wasmHandler } from "https://esm.town/v/maxm/tinygoHttp"; const resp = await fetch("https://maxm-wasmblobhost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm"); const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer())); export default async function(req: Request): Promise<Response> { return handler(req); }
HTTP
const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
export default async function(req: Request): Promise<Response> {
return handler(req);
VallSter avatar
valentine
@VallSter
Hello!!! Feel free to mess around with this val and make it your own :). Just click on "Fork" in the top right. You can change the phrases that show up as you click no, you can change the firstImg and secondImg, maybe even add more images. And you can also change the colors and any of the text on the screen! Have fun with it and hopefully your crush says yes hehe.
HTTP
"Alright, that's it. I’m going to dramatically stare out of a window in the rain now. β˜”πŸ˜­",
function App() {
const [noClicks, setNoClicks] = useState(0);
</div>
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(
justbe avatar
denoWasmModuleChanged
@justbe
denoWasmModuleChanged This val is used to update the wasm.rs file in my wasm-to-dts repo to match that of the deno_graph crate. When it detects that deno_graph has updated it invokes the workflow_dispatch in my GitHub actions.
Cron
throw new Error("GITHUB_TOKEN environment variable is not set");
const octokit = new Octokit({ auth: GITHUB_TOKEN });
export default async function(interval: Interval) {
const lastHash = await blob.getJSON<string>(WASM_HASH_KEY) ?? "";
const hash = await hashUrlContent(
liamdanielduffy avatar
selfEmbeddedNoFramework
@liamdanielduffy
// https://www.val.town/embed/liamdanielduffy.selfEmbedded
Script
export async function selfEmbeddedNoFramework(
function makeResizable(element) {
function initResize(e) {
function resize(e) {
function stopResize() {
function makeDraggable(element) {
function startDrag(e) {
function drag(e) {
function stopDrag() {
iframe.addEventListener('mousedown', function (e) {
stungeye avatar
trpc
@stungeye
An interactive, runnable TypeScript val by stungeye
Script
import { fetch } from "https://esm.town/v/std/fetch";
export async function trpc(userHandle, valName) {
return await fetch(
`https://www.val.town/api/trpc/getValReferenceTypes?input={%22userHandle%22:%22${userHandle}%22,%22valName%22:%22${valNam
jamiedubs avatar
simpleJsonReply
@jamiedubs
// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
Express (deprecated)
// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
export async function expressHTMLExample(
req: express.Request,
res: express.Response,
neverstew avatar
preactTest
@neverstew
An interactive, runnable TypeScript val by neverstew
HTTP
"https://npm.reversehttp.com/preact,htm,preact/hooks,preact-render-to-string"
const html = htm.bind(h);
function Component() {
const [count, setCount] = useState(0);
const inc = () => setCount(count => count + 1);
jaandrle avatar
mastodon$fetchInstanceStats
@jaandrle
An interactive, runnable TypeScript val by jaandrle
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export async function mastodon$fetchInstanceStats(instance) {
const url = "https://" + instance + "/api/v1/instance/activity";
const stats = await fetchJSON(url).catch((e) => e);
daisuke avatar
postHogAPICapture
@daisuke
An interactive, runnable TypeScript val by daisuke
Script
import { fetch } from "https://esm.town/v/std/fetch";
export async function postHogAPICapture({ key, event, properties, distinct_id }: {
key: string;
event: string;