sqliteExplorerAppREADME.md1 match
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
versatileWhiteJaymain.tsx3 matches
24];
2526function IndianMovieExplorer() {
27const [searchTerm, setSearchTerm] = useState("");
28const [actors, setActors] = useState([]);
311}
312313function client() {
314createRoot(document.getElementById("root")).render(<IndianMovieExplorer />);
315}
317if (typeof document !== "undefined") { client(); }
318319export default async function server(request: Request) {
320return new Response(`
321<html>
3import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
45function LoginScreen({ onLogin }) {
6const [password, setPassword] = useState("");
7const [error, setError] = useState("");
46}
4748function CustomerInteractionForm({ onSubmit }) {
49const [email, setEmail] = useState("");
50const [firstName, setFirstName] = useState("");
240}
241242function InteractionList() {
243const [customerInteractions, setCustomerInteractions] = useState({});
244const [copiedEmail, setCopiedEmail] = useState(null);
470}
471472function App() {
473const [isAuthenticated, setIsAuthenticated] = useState(false);
474const [refreshList, setRefreshList] = useState(0);
517}
518519function client() {
520createRoot(document.getElementById("root")).render(<App />);
521}
522if (typeof document !== "undefined") { client(); }
523524export default async function server(request: Request): Promise<Response> {
525const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
526const KEY = "CRM";
webAppForRDSBlueGreenmain.tsx3 matches
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45function PostgreSQLParameterCalculator() {
6const instanceTypes = [
7{
261}
262263function client() {
264createRoot(document.getElementById("root")).render(<PostgreSQLParameterCalculator />);
265}
267if (typeof document !== "undefined") { client(); }
268269export default async function server(request: Request): Promise<Response> {
270return new Response(`
271<html>
5import { renderToString } from "npm:react-dom/server";
67function StatusRow({ rows }) {
8return (
9<div className="w-full flex flex-col space-y-2">
28}
2930function StatusSection({ url, rows }) {
31const sectionRows = rows.filter(row => row[0] === url);
32const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
4546export default async function(req: Request): Promise<Response> {
47const { rows } = await sqlite.execute(
48"select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",
isMyWebsiteDownmain.tsx1 match
6);
78export async function uptimeCheck(url: string) {
9let ok = true;
10let reason: string;
OpenTowniesystem_prompt.txt17 matches
101. `http`: http vals export a default server request handler.
112. `script`: script vals can be imported into other vals, similar to an npm package.
123. `cron`: cron vals export a function that can automatically run at user-set intervals, similar to a cron command.
134. `email`: email vals export a function that runs when its associated email address receives an email.
1415Follow these requirements for Val Town when generating code.
49</requirements>
5051If the user asks for specific functionality, the Val Town standard library includes the following:
5253<libraries>
63```
6465Blob storage only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:
66`const { blob } = await import("https://esm.town/v/std/blob");`
67</library>
78If you are changing a SQLite table's schema, you should also change the table's name so it creates a fresh table, ie by adding _2 or _3 after it everywhere. Ensure that tables are created before they are used.
7980SQLite storage only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:
81`const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");`
82</library>
99```
100101OpenAI only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:
102`const { OpenAI } = await import "https://esm.town/v/std/openai");`
103</library>
113```
114115Email only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:
116`const { email } = await import "https://esm.town/v/std/email");`
117</library>
131Write the code in ```val code fences.
132Include the val type as metadata on the code fence, e.g.: ```val type=script
133If this is a new val, decide what val type is appropriate based on the user's prompt. Default to choosing http type vals unless the user has requested specific functionality that requires a different type.
134135* If the user requests diff format in their prompt, follow these steps:
157* Use fetch to communicate with the backend server portion.
158*/
159function App() {
160return (
161<div>
167/**
168* Client-only code
169* Any code that makes use of document or window should be scoped to the `client()` function.
170* This val should not cause errors when imported as a module in a browser.
171*/
172function client() {
173createRoot(document.getElementById("root")).render(<App />);
174}
177/**
178* Server-only code
179* Any code that is meant to run on the server should be included in the server function.
180* This can include endpoints that the client side component can send fetch requests to.
181*/
182export default async function server(request: Request): Promise<Response> {
183/** If needed, blob storage or sqlite can be imported as a dynamic import in this function.
184* Blob storage should never be used in the browser directly.
185* Other server-side specific modules can be imported in a similar way.
232```val type=script
233/** Use this template for creating script vals only */
234export default function () {
235return "Hello, world";
236}
243```val type=cron
244/** Use this template for creating cron vals only */
245export default async function (interval: Interval) {
246// code will run at an interval set by the user
247console.log(`Hello, world: ${Date.now()}`);
270// The email address for this val will be `<username>.<valname>@valtown.email` which can be derived from:
271// const emailAddress = new URL(import.meta.url).pathname.split("/").slice(-2).join(".") + "@valtown.email";
272export default async function (e: Email) {
273console.log("Email received!", email.from, email.subject, email.text);
274}
OpenTownieindex4 matches
5import { generateCodeAnthropic, makeFullPrompt } from "./backend/generateCode";
67function App() {
8const [messages, setMessages] = useState<{ content: string; role: string }[]>([]);
9const [inputMessage, setInputMessage] = useState("make a todo app");
11const [bearerToken, _setBearerToken] = useState(localStorage.getItem("val-town-bearer"));
1213function setBearerToken(token: string) {
14_setBearerToken(token);
15localStorage.setItem("val-town-bearer", token);
79}
8081function client() {
82createRoot(document.getElementById("root")).render(<App />);
83}
84if (typeof document !== "undefined") { client(); }
8586export default async function server(req: Request): Promise<Response> {
87// console.log(req);
88if (req.method === "POST") {
OpenTowniegenerateCode2 matches
1import OpenAI from "https://esm.sh/openai";
23function parseValResponse(response: string) {
4const codeBlockRegex = /```val type=(\w+)\n([\s\S]*?)```/;
5const match = response.match(codeBlockRegex);
25}
2627export async function generateCodeAnthropic(messages: Message[]): Promise<ValResponse | null> {
28const system = await (await fetch(`${import.meta.url.split("/").slice(0, -1).join("/")}/system_prompt.txt`)).text();
29
HorrorGamemain.tsx3 matches
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45function HorrorGame() {
6const [gameState, setGameState] = useState({
7scene: "start",
88}
8990function client() {
91createRoot(document.getElementById("root")).render(<HorrorGame />);
92}
93if (typeof document !== "undefined") { client(); }
9495export default async function server(request: Request): Promise<Response> {
96return new Response(`
97<html>