3import { deleteCookie, getCookies, setCookie } from "jsr:@std/http/cookie";
4
5async function createSession(email: string, hostname: string) {
6 const sessionID = crypto.randomUUID();
7 const expiresAt = new Date();
23}
24
25async function getSession(sessionID: string, hostname: string) {
26 try {
27 const res = await sqlite.execute({
49}
50
51async function deleteSession(sessionID: string) {
52 await sqlite.execute({
53 sql: `DELETE FROM lastlogin_session WHERE sessionID=?`,
65};
66
67export function lastlogin(
68 handler: (req: Request) => Response | Promise<Response>,
69 options: LastLoginOptions,
1async function fetchUser(token: string): Promise<{ email: string }> {
2 const resp = await fetch("https://api.val.town/v1/me", {
3 headers: {
13}
14
15export async function verifyEmail(email: string) {
16 try {
17 const user = await fetchUser(Deno.env.get("valtown"));
4import { GoogleGenerativeAI } from "https://esm.sh/@google/generative-ai";
5
6function ProgressBar({ progress }) {
7 return (
8 <div className="w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700 mb-4">
16}
17
18function PostDetails({ post }) {
19 if (!post) return null;
20 const hnDiscussionUrl = `https://news.ycombinator.com/item?id=${post.id}`;
76}
77
78function App() {
79 const [postId, setPostId] = useState("");
80 const [postDetails, setPostDetails] = useState(null);
216}
217
218function client() {
219 console.log("Client function called");
220 const root = document.getElementById("root");
221 if (root) {
244}
245
246export default async function server(request: Request): Promise<Response> {
247 console.log("Server function called", request.method, request.url);
248
249 // Handle root GET request
279 <script>
280 console.log("Inline script executed");
281 window.addEventListener('load', function() {
282 console.log("Window load event fired");
283 setTimeout(function() {
284 var loadingMessage = document.getElementById('loading-message');
285 if (loadingMessage) {
11type PromptItem = typeof prompts[number];
12
13function Hero({
14 prompt,
15 setPrompt,
49
50 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
51 Turn your ideas into fully functional apps in{" "}
52 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
53 less than a second
120}
121
122function App() {
123 const previewRef = React.useRef<HTMLDivElement>(null);
124 const [prompt, setPrompt] = useState("");
173 });
174
175 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
176 setLoading(true);
177 setTimeout(() => handleSubmit(promptItem.prompt), 0);
178 }
179
180 async function handleSubmit(e: React.FormEvent | string) {
181 if (typeof e !== "string") {
182 e.preventDefault();
229 }
230
231 function handleVersionChange(direction: "back" | "forward") {
232 const { currentVersionIndex, versions } = versionHistory;
233 if (direction === "back" && currentVersionIndex > 0) {
992);
993
994function client() {
995 const path = window.location.pathname;
996 const root = createRoot(document.getElementById("root")!);
1028}
1029
1030function extractCodeFromFence(text: string): string {
1031 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1032 return htmlMatch ? htmlMatch[1].trim() : text;
1033}
1034
1035async function generateCode(prompt: string, currentCode: string) {
1036 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1037 if (starterPrompt) {
1074}
1075
1076export default async function server(req: Request): Promise<Response> {
1077 // Dynamic import for SQLite to avoid client-side import
1078 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
12type PromptItem = typeof prompts[number];
13
14function Hero({
15 prompt,
16 setPrompt,
50
51 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
52 Turn your ideas into fully functional apps in{" "}
53 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
54 less than a second
121}
122
123function App() {
124 const previewRef = React.useRef<HTMLDivElement>(null);
125 const [prompt, setPrompt] = useState("");
174 });
175
176 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
177 setLoading(true);
178 setTimeout(() => handleSubmit(promptItem.prompt), 0);
179 }
180
181 async function handleSubmit(e: React.FormEvent | string) {
182 if (typeof e !== "string") {
183 e.preventDefault();
230 }
231
232 function handleVersionChange(direction: "back" | "forward") {
233 const { currentVersionIndex, versions } = versionHistory;
234 if (direction === "back" && currentVersionIndex > 0) {
993);
994
995function client() {
996 const path = window.location.pathname;
997 const root = createRoot(document.getElementById("root")!);
1029}
1030
1031function extractCodeFromFence(text: string): string {
1032 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1033 return htmlMatch ? htmlMatch[1].trim() : text;
1034}
1035
1036async function generateCode(prompt: string, currentCode: string) {
1037 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1038 if (starterPrompt) {
1075}
1076
1077export default async function server(req: Request): Promise<Response> {
1078 // Dynamic import for SQLite to avoid client-side import
1079 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
777 }
778
779 function predictDraw(teamA, teamB, tournament) {
780 if (!teamA || !teamB) return 0;
781
782 // Helper function to calculate draw rate
783 const calculateDrawRate = (team) =>
784 team.results.draws / team.totalMatches;
39);
40
41function App() {
42 const [functionInput, setFunctionInput] = useState("");
43 const [mermaidDiagram, setMermaidDiagram] = useState("");
44 const [error, setError] = useState("");
70 "Content-Type": "application/json",
71 },
72 body: JSON.stringify({ function: functionInput }),
73 });
74
102 },
103 body: JSON.stringify({
104 functionDescription: functionInput,
105 currentMermaidCode: `\`\`\`mermaid\n${mermaidDiagram}\n\`\`\``,
106 }),
148 <div style={styles.container}>
149 <div style={styles.header}>
150 <h1 style={styles.title}>🔍 Function Diagram Generator</h1>
151 <p style={styles.subtitle}>Transform code into visual flowcharts</p>
152 </div>
154 <form onSubmit={handleSubmit} style={styles.form}>
155 <textarea
156 value={functionInput}
157 onChange={(e) => setFunctionInput(e.target.value)}
158 placeholder="Paste your function here... (JavaScript/TypeScript)"
159 style={styles.textarea}
160 rows={10}
334};
335
336function client() {
337 createRoot(document.getElementById("root")).render(<App />);
338}
339if (typeof document !== "undefined") { client(); }
340
341export default async function server(request: Request): Promise<Response> {
342 if (request.method === "PUT") {
343 try {
372 <html>
373 <head>
374 <title>Function Mermaid Diagram Generator</title>
375 <meta name="viewport" content="width=device-width, initial-scale=1">
376 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap" rel="stylesheet">
1import { runPythonCode } from "https://deno.land/x/py_town@v0.0.8/mod.ts";
2
3export default async function handler(req: Request): Promise<Response> {
4 const pythonCode = `
5import numpy as np
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const handlePostMessage = () => {
7 window.parent.postMessage('{"data": "foo", "field": "expected", "type": "update"}', '*');
29}
30
31function client() {
32 createRoot(document.getElementById("root")).render(<App />);
33}
34if (typeof document !== "undefined") { client(); }
35
36export default async function server(request: Request): Promise<Response> {
37 return new Response(`
38 <html>
2import { wholefoodssales } from "https://esm.town/v/Glench/wholefoodssales";
3
4export default async function(req: Request): Promise<Response> {
5 return new Response(dataToRSS(await wholefoodssales(), {
6 title: "Whole Foods Sales — Personal",