4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [file, setFile] = useState(null);
8 const [tableName, setTableName] = useState("");
66}
67
68function client() {
69 createRoot(document.getElementById("root")).render(<App />);
70}
72if (typeof document !== "undefined") { client(); }
73
74export default async function server(request: Request): Promise<Response> {
75 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
76 const { parse } = await import("https://esm.sh/csv-parse/sync");
79 const KEY = "csvToSqliteUploader";
80
81 function sanitizeColumnName(name: string): string {
82 return name.replace(/[^a-zA-Z0-9_]/g, "_").replace(/^(\d)/, "_$1");
83 }
42);
43
44export default async function(req: Request): Promise<Response> {
45 return Response.json(
46 await db.query(`
2// It supports generating square images with a single dimension parameter or rectangular images with two dimension parameters.
3
4export default async function server(request: Request): Promise<Response> {
5 const url = new URL(request.url);
6 const parts = url.pathname.split('/').filter(Boolean);
95 <p>Start generating your own kitten images by using the form above or modifying the URL!</p>
96 <script>
97 document.getElementById('kittenForm').addEventListener('submit', function(e) {
98 e.preventDefault();
99 const width = document.getElementById('width').value;
3import { createRoot } from "https://esm.sh/react-dom/client";
4// last stable version is v138
5function App() {
6 const [url, setUrl] = useState("");
7 const [result, setResult] = useState(null);
68}
69
70function client() {
71 console.log("Initializing client-side React application");
72 createRoot(document.getElementById("root")).render(<App />);
77}
78
79async function scrapePage(url) {
80 console.log(`Starting to scrape page: ${url}`);
81 const apiKey = Deno.env.get("ScrapingBeeAPIkey");
163}
164
165async function getApiKey() {
166 const apiKey = Deno.env.get("ScrapingBeeAPIkey");
167 if (!apiKey) {
172}
173
174async function server(request) {
175 console.log(`Received ${request.method} request for path: ${new URL(request.url).pathname}`);
176 if (request.method === "POST" && new URL(request.url).pathname === "/scrape") {
15
16 - The client-side React component makes a fetch request to "/image".
17 - This request is handled by our server function.
18
19
202. Server-side handling:
21
22 - The server function calls `blob.get("test.png")`.
23 - This `blob.get()` method makes an HTTP request to the Val Town API.
24 - The API returns a Response object containing the image data.
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "Philadelphia"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });
8SyntaxHighlighter.registerLanguage('json', json);
9
10function App() {
11 const [jsonInput, setJsonInput] = useState('');
12 const [parsedJson, setParsedJson] = useState('');
57}
58
59function client() {
60 createRoot(document.getElementById("root")).render(<App />);
61}
63if (typeof document !== "undefined") { client(); }
64
65export default async function server(request: Request): Promise<Response> {
66 return new Response(`
67 <html>
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [websiteUrl, setWebsiteUrl] = useState("");
7 const [embedCode, setEmbedCode] = useState("");
61}
62
63function client() {
64 createRoot(document.getElementById("root")).render(<App />);
65}
69}
70
71async function server(request: Request): Promise<Response> {
72 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
73 const SCHEMA_VERSION = 1;
92import { useState, useEffect } from 'react';
93
94function VisitorCounter() {
95 const [count, setCount] = useState(0);
96
15
16// Use Browserbase (with proxy) to search and scrape Reddit results
17export async function redditSearch({
18 query,
19 apiKey = Deno.env.get("BROWSERBASE_API_KEY"),
46}
47
48function constructSearchUrl(query: string): string {
49 const encodedQuery = encodeURIComponent(query).replace(/%20/g, "+");
50 return `https://www.reddit.com/search/?q=${encodedQuery}&type=link&t=week`;
51}
52
53async function extractPostData(page: any): Promise<Partial<ThreadResult>[]> {
54 return page.evaluate(() => {
55 const posts = document.querySelectorAll("div[data-testid=\"search-post-unit\"]");
67}
68
69async function processPostData(postData: Partial<ThreadResult>[]): Promise<ThreadResult[]> {
70 const processedData: ThreadResult[] = [];
71
11};
12
13async function createSessionTable(tableName: string) {
14 await sqlite.execute(`CREATE TABLE ${tableName} (
15 id TEXT NOT NULL PRIMARY KEY,
19}
20
21async function createSession(tableName: string, valSlug: string): Promise<Session> {
22 try {
23 const expires_at = new Date();
39}
40
41async function getSession(tableName: string, sessionID: string, valSlug: string): Promise<Session> {
42 try {
43 const { rows, columns } = await sqlite.execute({
80</html>`;
81
82export function redirect(location: string): Response {
83 return new Response(null, {
84 headers: {
98const cookieName = "auth_session";
99
100export function passwordAuth(next, options?: PasswordAuthOptions) {
101 const sessionTable = options?.sessionTable || "password_auth_session";
102 return async (req: Request) => {