3const php = new PhpWeb();
4
5export default async function(req: Request): Promise<Response> {
6 let output = "";
7 let headers = new Headers();
55
56 // Simple router
57 function route($uri, $method) {
58 switch ($uri) {
59 case '/api':
79 <title>Greeting Form</title>
80 <script>
81 async function submitForm(event) {
82 event.preventDefault();
83 const form = event.target;
3const php = new PhpWeb();
4
5export default async function(req: Request): Promise<Response> {
6 let output = "";
7 let headers = new Headers();
55
56 // Simple router
57 function route($uri, $method) {
58 switch ($uri) {
59 case '/api':
79 <title>Greeting Form</title>
80 <script>
81 async function submitForm(event) {
82 event.preventDefault();
83 const form = event.target;
2import { email } from "https://esm.town/v/std/email";
3
4export default async function questionPractice(interval: Interval) {
5 const contents = await arenaChannelContents({ channelId: "asking-the-right-questions-sbkcnb9eank" });
6 const textContents = contents.filter(item => item.class === "Text");
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
4// We'll use the built-in URL constructor for basic URL validation and the native fetch for HTTP requests.
5// The UI is now styled using Tailwind CSS and shadcn UI components for a more polished look.
6// Added functionality to show the selected filename in the UI.
7
8import { parse } from "https://deno.land/std@0.182.0/encoding/csv.ts";
9import { stringify } from "https://deno.land/std@0.182.0/encoding/csv.ts";
10
11export default async function main(req: Request): Promise<Response> {
12 if (req.method === "GET") {
13 // Return HTML form for file upload with shadcn UI styling
45 </div>
46 <script>
47 document.getElementById('file-upload').addEventListener('change', function(e) {
48 var fileName = e.target.files[0].name;
49 document.getElementById('file-name').textContent = 'Selected file: ' + fileName;
2 * Returns a response to the user's query
3 */
4async function getResponse(req: Query, send: SendEventFn) {
5 send("meta", { content_type: "text/markdown" });
6 let i = 0;
19}
20
21function chunk(i: number) {
22 return `# Heading ${i}
23
33 * Returns your bot's settings
34 */
35async function getBotSettings(): Promise<BotSettings> {
36 return {
37 allow_attachments: true,
104) => void;
105
106function encodeEvent(event: string, data: any = {}) {
107 return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
108}
109
110export default async function(req: Request): Promise<Response> {
111 const reqBody = await req.json()
112 .catch((e) => {
3
4// Get the title of the top story on Hacker News
5export async function hnTopStory() {
6 const topStories: Number[] = await fetch(
7 "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty",
2 * Returns a response to the user's query
3 */
4async function getResponse(req: Query, send: SendEventFn) {
5 send("meta", { content_type: "text/markdown" });
6 send("text", {
27 * Returns your bot's settings
28 */
29async function getBotSettings(): Promise<BotSettings> {
30 return {
31 allow_attachments: true,
98) => void;
99
100function encodeEvent(event: string, data: any = {}) {
101 return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
102}
103
104export default async function(req: Request): Promise<Response> {
105 const reqBody = await req.json()
106 .catch((e) => {
2 * Returns a response to the user's query
3 */
4async function getResponse(req: Query, send: SendEventFn) {
5 send("meta", { content_type: "text/markdown" });
6 const lastMessage = req.query.at(-1);
25 * Returns your bot's settings
26 */
27async function getBotSettings(): Promise<BotSettings> {
28 return {
29 allow_attachments: true,
87) => void;
88
89function encodeEvent(event: string, data: any = {}) {
90 return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
91}
92
93export default async function(req: Request): Promise<Response> {
94 const reqBody = await req.json().catch((e) => {
95 console.error("body parse error", e);
2 * Returns a response to the user's query
3 */
4async function getResponse(req: Query, send: SendEventFn) {
5 send("meta", { content_type: "text/markdown" });
6 const lastMessage = req.query.at(-1);
19 * Returns your bot's settings
20 */
21async function getBotSettings(): Promise<BotSettings> {
22 return {
23 allow_attachments: true,
90) => void;
91
92function encodeEvent(event: string, data: any = {}) {
93 return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
94}
95
96export default async function(req: Request): Promise<Response> {
97 const reqBody = await req.json().catch((e) => {
98 console.error("body parse error", e);