Search

Results include substring matches and semantically similar vals. Learn more
hbcoop avatar
linkInBioTemplate
@hbcoop
@jsxImportSource https://esm.sh/react@17.0.2
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react@17.0.2 */
import { renderToString } from "https://esm.sh/react-dom@17.0.2/server";
import React from "https://esm.sh/react@17.0.2";
const gradientBackground: React.CSSProperties = {
background: "linear-gradient(135deg, #00a8e8 0%, #007ea7 100%)",
justifyContent: "center",
const containerStyle: React.CSSProperties = {
padding: "30px",
boxShadow: "0 10px 30px rgba(0, 0, 0, 0.1)",
const headingStyle: React.CSSProperties = {
color: "#ffffff",
marginBottom: "10px",
const subheadingStyle: React.CSSProperties = {
color: "#e0f7fa",
marginBottom: "20px",
const buttonContainerStyle: React.CSSProperties = {
display: "flex",
gap: "15px",
const buttonStyle: React.CSSProperties = {
padding: "12px",
stevekrouse avatar
grievingYellowAsp
@stevekrouse
Perf - a website performance tester I had Anthropic build this for me to show off the launch of HTTP (Preview) vals: https://blog.val.town/blog/http-preview/
HTTP
/** @jsxImportSource https://esm.sh/react */
import pLimit from "https://esm.sh/p-limit";
import React, { useCallback, useState } from "https://esm.sh/react";
import { hydrateRoot } from "https://esm.sh/react-dom/client";
import { renderToReadableStream } from "https://esm.sh/react-dom/server";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
: "N/A";
// React components
const TestForm = ({ onSubmit, isLoading }) => {
pomdtr avatar
http_client
@pomdtr
HTTP Client Attach a postman-like http client to your vals, with bookmarks and history support Usage Wrap your http handler in an the httpClient middleware. import {httpClient} from "https://esm.town/v/pomdtr/http_client" export default httpClient((req) => { return new Response("Hello World!") }) The http client will be shown on the root. Adding bookmarks You might want to bookmark some requests you need often. You can do it by passing a bookmark list as a middleware option: import {httpClient} from "https://esm.town/v/pomdtr/http_client" export default httpClient((req) => { return new Response("Hello World!") }, { bookmarks: [ { "label": "Dummy Request", "request": new Request("https://dummyjson.com/products") } ]}) Customizing the client path import {httpClient} from "https://esm.town/v/pomdtr/http_client" export default httpClient((req) => { return new Response("Hello World!") }, { path: "/http-client" }) TODO [ ] fix syntax highlighting on successive request [ ] allow to prefill the initial request
HTTP (deprecated)
# HTTP Client
Attach a postman-like http client to your vals, with bookmarks and history support
Wrap your http handler in an the httpClient middleware.
import {httpClient} from "https://esm.town/v/pomdtr/http_client"
export default httpClient((req) => {
/** @jsxImportSource npm:preact **/
import { render } from "npm:preact-render-to-string";
<title>REST Client</title>
<script type="module" src="https://esm.town/v/pomdtr/http_client_component"></script>
export function httpClient(next: (req: Request) => Response | Promise<Response>, options: {
niek avatar
cyanGuppy
@niek
// Uncomment this line for one run of the Val to create the DB lol
HTTP (deprecated)
export let spotifyRequestToken = ({ client_id, client_secret, code, redirect_uri }) =>
"Authorization": "Basic " + (new Buffer(client_id + ":" + client_secret).toString("base64")),
export let spotifyRefreshToken = async ({ refresh_token, client_id, client_secret }) =>
"Authorization": "Basic " + (new Buffer(client_id + ":" + client_secret).toString("base64")),
`https://accounts.spotify.com/authorize?response_type=code&client_id=${
encodeURIComponent(Deno.env.get("SPOTIFY_CLIENT_ID"))
client_id: Deno.env.get("SPOTIFY_CLIENT_ID"),
client_secret: Deno.env.get("SPOTIFY_CLIENT_SECRET"),
client_id: Deno.env.get("SPOTIFY_CLIENT_ID"),
client_secret: Deno.env.get("SPOTIFY_CLIENT_SECRET"),
jesusgollonet avatar
socialMetaTest
@jesusgollonet
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
const description = "social meta test";
stevekrouse avatar
perf
@stevekrouse
Perf - a website performance tester I had Anthropic build this for me to show off the launch of HTTP (Preview) vals: https://blog.val.town/blog/http-preview/
HTTP
/** @jsxImportSource https://esm.sh/react */
import pLimit from "https://esm.sh/p-limit";
import React, { useCallback, useState } from "https://esm.sh/react";
import { hydrateRoot } from "https://esm.sh/react-dom/client";
import { renderToReadableStream } from "https://esm.sh/react-dom/server";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
: "N/A";
// React components
const TestForm = ({ onSubmit, isLoading }) => {
djs avatar
linkInBioTemplate
@djs
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
return new Response(
stevekrouse avatar
valTownChatGPT
@stevekrouse
ChatGPT Implemented in Val Town Demonstrated how to use assistants and threads with the OpenAI SDK and how to stream the response with Server-Sent Events
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import OpenAI from "npm:openai";
import { renderToString } from "npm:react-dom/server";
const openai = new OpenAI();
return new Response(renderToString(jsx), { headers: { "Content-Type": "text/html" } });
const clientCode = () => {
document.getElementById("input").addEventListener("submit", function(event) {
</form>
<script dangerouslySetInnerHTML={{ __html: `(${clientCode.toString()})()` }}>
</script>
iamseeley avatar
multirouteVue
@iamseeley
🌐 Multi-Route Website with Vue
HTTP (deprecated)
* @title Multi-Route Website with Vue in Val Town
* @description Create a personal portfolio website with multiple pages using Vue 3 and server-side rendering.
import { createSSRApp, h } from 'npm:vue@3';
h('p', {}, [
h('strong', {}, 'This website is rendered server-side with Vue.')
h('p', {}, [
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${personalData.name} | Server-side Vue</title>
<style>
yawnxyz avatar
nighthawksChat
@yawnxyz
It's Late. Get a drink. Have a chat. Welcome to Nighthawks. Nighthawks is an experiment in building interesting NPC characters with AI. The system combines large language models, simulates conversations using character sheets, and attempts to build memories based on the conversation. Improvise, have fun. Approach them like you would at a late night diner. Inspired by the Nighthawks painting. Built on a stripped down agent-based memory system.
HTTP (deprecated)
return nighthawks.characters[0];
return null;
// Server-side rendering
app.get("/", async (c) => {
const charId = c.req.query("char");
roadlabs avatar
valledrawclient
@roadlabs
@jsxImportSource https://esm.sh/react@18.3.1
Script
/** @jsxImportSource https://esm.sh/react@18.3.1 **/
// "react-dom": "18.3.1",
// "react": "18.3.1",
// "@reecelucas/react-use-hotkeys": "2.0.0",
// export * as ReactDOM from "react-dom";
// export * as React from "react";
// import useHotkeys from "@reecelucas/react-use-hotkeys";
window.makeValleDrawClient({
(window as any).makeValleDrawClient = async function({ iframeSrc, model }) {
ReactDOM,
ejfox avatar
allvals
@ejfox
An interactive, runnable TypeScript val by ejfox
HTTP
try {
debugMessages.push("Starting server-side processing");
const token = Deno.env.get('valtown');
debugMessages.push("Valtown token retrieved from environment");
const client = new ValTown({ apiKey: token });
debugMessages.push("ValTown client initialized");
const username = 'ejfox';
try {
user = await client.alias.username.retrieve(username);
debugMessages.push(`User data retrieved: ${JSON.stringify(user)}`);
try {
for await (const val of client.users.vals.list(user.id, { limit: 100 })) {
vals.push(val);
pomdtr avatar
blog_mdx
@pomdtr
@jsxImportSource https://esm.sh/preact
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/preact **/
import { blob } from "https://esm.town/v/std/blob?v=12";
import { Hono } from "npm:hono";
import { render } from "npm:preact-render-to-string";
import remarkFrontmatter from "npm:remark-frontmatter";
jsx: true,
jsxImportSource: "https://esm.sh/preact",
remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter],
const vfile = await compile(await resp.text(), {
jsxImportSource: "https://esm.sh/preact",
remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter],
yawnxyz avatar
deletebio
@yawnxyz
An interactive, runnable TypeScript val by yawnxyz
HTTP (deprecated)
float[] sizes = {1.0, 0.85, 0.7, 0.55, 0.4};
int[] sides = {6, 12, 8, 6, 4};
for (int i = 0; i < sizes.length; i++) {
drawPolygon(sides[i], hexagonSize * sizes[i]);
void drawPolygon(int sides, float size) {
beginShape();
for (int i = 0; i < sides; i++) {
float angle = TWO_PI / sides * i;
float x = cos(angle) * size;
rasputinkaiser avatar
linkInBioTemplate
@rasputinkaiser
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect, createContext, useContext } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
// ... (previous AuthContext, AuthProvider, and useAuth remain the same)
fontStyle: 'italic',
// ... (client and server functions remain the same)