81 setIsAIThinking(true);
82 try {
83 const response = await fetch("/ai-move", {
84 method: "POST",
85 headers: {
20
21 try {
22 const response = await fetch(window.location.origin + '/generate-python-help', {
23 method: 'POST',
24 headers: {
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
9
10 useEffect(() => {
11 async function fetchWeather() {
12 try {
13 setLoading(true);
14 const response = await fetch(
15 `https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}¤t_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m`,
16 );
19 setLoading(false);
20 } catch (error) {
21 console.error("Weather fetch error:", error);
22 setLoading(false);
23 }
24 }
25
26 fetchWeather();
27 }, [location]);
28
33
34 if (loading) return <div>Loading weather data...</div>;
35 if (!weatherData) return <div>Unable to fetch weather</div>;
36
37 return (
34 try {
35 const endpoint = isLogin ? '/login' : '/signup';
36 const response = await fetch(endpoint, {
37 method: 'POST',
38 headers: { 'Content-Type': 'application/json' },
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
15 e.preventDefault();
16 try {
17 const response = await fetch('/login', {
18 method: 'POST',
19 headers: { 'Content-Type': 'application/json' },
43
44 try {
45 const response = await fetch('/upload', {
46 method: 'POST',
47 body: formData
50 if (data.success) {
51 alert('File uploaded successfully');
52 fetchUploadedFiles();
53 }
54 } catch (error) {
59 const generateLoginCode = async () => {
60 try {
61 const response = await fetch('/generate-code', { method: 'POST' });
62 const data = await response.json();
63 setGeneratedCode(data.code);
67 };
68
69 const fetchUploadedFiles = async () => {
70 try {
71 const response = await fetch('/files');
72 const data = await response.json();
73 setUploadedFiles(data);
74 } catch (error) {
75 console.error('Failed to fetch files', error);
76 }
77 };
79 useEffect(() => {
80 if (isAdmin) {
81 fetchUploadedFiles();
82 }
83 }, [isAdmin]);
269 }
270
271 // Fetch files
272 if (request.method === 'GET' && new URL(request.url).pathname === '/files') {
273 const result = await sqlite.execute(`
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
54 headers: {
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({