Search
valle_tmp_459423574352421057264033168224449
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: `Sample Story ${idx + 1}`,
url: `https://example.com/story${idx + 1}`,
votes: Math.floor(Math.random() * 100),
shirtGenScript
@torlanco
š Shirtgen API Endpoint Shirtgen lets you generate AI-powered t-shirt designs with just a prompt! šļø Choose between the standard "Flux Schnell" model or the enhanced "Pro" model. Perfect for creating unique custom apparel in seconds! š š” How it Works Send a POST request to the endpoint with your design prompt. Toggle between Standard and Pro models using the useProModel flag. The AI generates a high-quality t-shirt design based on your prompt. š„ Expected POST Data {
"prompt": "A retro sunset with palm trees š“š
",
"useProModel": true
}
HTTP
š **Shirtgen API Endpoint**
Shirtgen lets you generate AI-powered t-shirt designs with just a prompt! šļø Choose between the standard "Flux Schnell" model or the enhanced "Pro" model. Perfect for creating unique custom apparel in seconds! š
### š” How it Works
1. Send a `POST` request to the endpoint with your design prompt.
2. Toggle between **Standard** and **Pro** models using the `useProModel` flag.
3. The AI generates a high-quality t-shirt design based on your prompt.
export default async function server(request: Request): Promise<Response> {
if (request.method !== "POST") {
return new Response("Method Not Allowed", { status: 405 });
const { prompt, useProModel } = await request.json();
GenerateQR
@ramkarthik
// fetch("https://api.val.town/v1/express/ramkarthik.GenerateQR?url={url}"
Express (deprecated)
// fetch("https://api.val.town/v1/express/ramkarthik.GenerateQR?url={url}"
export async function GenerateQR(req, res) {
const url = req.query.url;
res.set("Content-Type", "text/html");
if (!url) {
res.send(
"<html><body>Not a valid URL - " + JSON.stringify(req.query) +
"</body></html>",
const { qrcode } = await import("https://deno.land/x/qrcode/mod.ts");
const base64Image = await qrcode(url);
valle_tmp_3047705681953123466702705463047245
@janpaul123
// This script creates an HTTP val that responds with "Hello World" using some CSS styling to make it look cool.
HTTP
// This script creates an HTTP val that responds with "Hello World" using some CSS styling to make it look cool.
// We'll set up a basic HTML structure and use internal CSS to style the text.
* This function handles incoming HTTP requests and returns a styled HTML response.
export default function(req: Request): Response {
// The CSS styles we will apply
const css = `
body {
display: flex;
justify-content: center;
align-items: center;
eval_
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export let eval_ = (code, args?) =>
fetchJSON("https://api.val.town/v1/eval", {
method: "POST",
body: JSON.stringify({
code,
args,
stream
@tempguy
@jsxImportSource npm:hono@3/jsx
HTTP
/** @jsxImportSource npm:hono@3/jsx */
const Fetch = fetch;
interface ShowBox {
code: number;
msg: string;
server_runtime: number;
server_name: string;
data: {
link: string;
function getSeasonEpisode(text) {
free_open_router
@taras
curl 'https://taras-free_open_router.web.val.run/api/v1/chat/completions' \
-H 'accept: application/json' \
-H 'authorization: Bearer THIS_IS_OVERRIDEN_ON_SERVER' \
-H 'content-type: application/json' \
--data-raw '{
"model": "auto",
"temperature": 0,
"messages": [
{
"role": "system",
"content": "stuff"
},
{
"role": "user",
"content": "hello"
}
],
"stream": true
}'
HTTP
curl 'https://taras-free_open_router.web.val.run/api/v1/chat/completions' \
-H 'accept: application/json' \
-H 'authorization: Bearer THIS_IS_OVERRIDEN_ON_SERVER' \
-H 'content-type: application/json' \
--data-raw '{
"model": "auto",
const COMPLETION = "/api/v1/chat/completions";
const MODELS = "/api/v1/models";
const supported_urls = [COMPLETION, MODELS];
const isValTown = Deno.env.get("VALTOWN_API_URL");
valle_tmp_3011947751662660376708881415586205
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: `Sample Story ${idx + 1}`,
url: `https://example.com/story${idx + 1}`,
votes: Math.floor(Math.random() * 100),
wee2
@val
An interactive, runnable TypeScript val by val
Script
import { fetchJSON } from "https://esm.town/v/val/fetchJSON";
export let wee2 = fetchJSON(
"https://api.val.town/express/@val.wee1",
method: "POST",
body: JSON.stringify({ name: "Steve" }),
basicsWithBabishRss
@diit
An interactive, runnable TypeScript val by diit
Script
export async function basicsWithBabishRss(req: express.Request, res) {
const { Feed } = await import("npm:feed");
// function toTitleCase(str) {
// return str.replace(/\w\S*/g, function (txt) {
// return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
async function generateRssFeed() {
const { parseDocument } = await import("npm:htmlparser2");
const response = await fetch("https://basicswithbabish.co/episodes");
const body = await response.text();
const dom = parseDocument(body);
val_IqQ0SMdyJQ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_IqQ0SMdyJQ(req) {
try {
// Execute the code directly
const findPrimes = (max) => {
const primes = [];
for (let num = 2; num < max; num++) {
let isPrime = true;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) {
isPrime = false;
valle_tmp_09983323334565619759844043742776
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = [
{ id: 1, title: "Show HN: This website recreates the feeling of playing a roguelike in a terminal", url: "https://example.com/story1", votes: 75 },
{ id: 2, title: "Ask HN: How do I learn Deno?", url: "https://example.com/story2", votes: 150 },
{ id: 3, title: "Tell HN: I built a new static site generator", url: "https://example.com/story3", votes: 200 },
{ id: 4, title: "Launch HN: We're Kicking off our New AI Service for Developers", url: "https://example.com/story4", votes: 50 },
valle_tmp_04779227870600944224693473656022
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
const SAMPLE_STORIES_KEY = "hn_sample_stories";
// Initialize sample stories and store them in blob storage
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: faker.lorem.sentence(),
url: faker.internet.url(),
votes: faker.datatype.number({ min: 0, max: 100 }),
Html
@curtcox
An interactive, runnable TypeScript val by curtcox
Script
export function h2(value) { return `<h2>${value}</h2>`; }
export function li(value) { return `<li>${value}</li>`; }
export function td(value) { return `<td>${value}</td>`; }
export function th(value) { return `<th>${value}</th>`; }
export function tr(...cells) { return `<tr>${cells.join('')}</tr>`; }
export function ul(...items) { return `<ul>${items.join('')}</ul>`; }
export function table(...items) { return `<table>${items.join('')}</table>`; }
export function bordered(...items) { return `<table border>${items.join('')}</table>`; }
export function a(href,label) { return `<a href="${href}">${label}</a>`; }
export function download(label,href,filename) { return `<a href="${href}" download="${filename}">${label}</a>`; }
valToModule
@easrng
An interactive, runnable TypeScript val by easrng
Express (deprecated)
export async function valToModule(req: express.Request, res: express.Response) {
try {
const { transpileVal } = await import(
"https://val2module.glitch.me/script.js?13"
const baseUrl = "https://" + req.get("host") + "/module/";
const [userHandle, valName] = req.path.split("/").slice(1).map((e) =>
decodeURIComponent(e)
).slice(-2);
res.type("js").send(
await transpileVal({