1/** @jsxImportSource npm:hono/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
1export default async function(req: Request): Promise<Response> {
2 const catResponse = await fetch("https://api.thecatapi.com/v1/images/search");
3 const [catData] = await catResponse.json();
4
21 window.addEventListener('beforeunload', handleUnload);
22
23 // Fetch initial messages after clearing
24 fetchMessages().catch(err => {
25 console.error("Initial message fetch failed:", err);
26 setError("Could not load messages. Please try again.");
27 });
37 const clearPreviousMessages = async () => {
38 try {
39 const response = await fetch('/clear-messages', {
40 method: 'POST'
41 });
57 }, [messages]);
58
59 const fetchMessages = async () => {
60 try {
61 const response = await fetch("/messages");
62 if (!response.ok) {
63 throw new Error(`HTTP error! status: ${response.status}`);
67 setError(null);
68 } catch (error) {
69 console.error("Failed to fetch messages:", error);
70 setError("Failed to load messages. Please check your connection.");
71 }
77
78 try {
79 const response = await fetch("/send-message", {
80 method: "POST",
81 headers: {
101 setNewMessage("");
102
103 // Fetch AI response
104 const aiResponse = await fetch("/get-response", {
105 method: "POST",
106 headers: {
271 }
272
273 // Fetch messages route
274 if (pathname === "/messages" && request.method === "GET") {
275 const messages = await sqlite.execute(`
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
8 headers: {
9 "User-Agent": "", // to transpile TS to JS
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
8 headers: {
9 "User-Agent": "", // to transpile TS to JS
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
21 }
22
23 const response = await fetch('/bfhl', {
24 method: 'POST',
25 headers: { 'Content-Type': 'application/json' },
42 document.getElementById("signupForm").addEventListener("submit", function(event) {
43 event.preventDefault();
44 fetch('/register', {
45 method: 'POST',
46 headers: { 'Content-Type': 'application/json' },
55 document.getElementById("attendanceForm").addEventListener("submit", function(event) {
56 event.preventDefault();
57 fetch('/submit-attendance', {
58 method: 'POST',
59 headers: { 'Content-Type': 'application/json' },
2 try {
3 // 获取外部URL的内容
4 const response = await fetch("https://esm.town/v/sky_porie_fire443/TestSlime/index.html");
5
6 // 检查是否成功获取
7 if (!response.ok) {
8 throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
9 }
10