File size: 1,031 Bytes
cb847aa
 
 
 
 
98026c4
cb847aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Function to fetch and display the contents of a folder
function listFolderContents() {
    const folderContents = document.getElementById('folder-contents');

    // Replace 'your-folder-path/' with the path to your folder
    const folderPath = 'spidey/';

    // Fetch a list of files and subfolders in the folder
    fetch(folderPath)
        .then(response => response.text())
        .then(data => {
            const items = data.split('\n').filter(item => item.trim() !== '');

            // Create an unordered list to display the contents
            const ul = document.createElement('ul');

            items.forEach(item => {
                const li = document.createElement('li');
                li.textContent = item;
                ul.appendChild(li);
            });

            folderContents.appendChild(ul);
        })
        .catch(error => console.error('Error loading folder contents:', error));
}

// Call the function to list folder contents when the page loads
window.onload = listFolderContents;