Spaces:
BG5
/
Running

File size: 1,545 Bytes
fcbf538
 
 
 
 
 
 
 
6324708
fcbf538
 
 
 
6324708
 
 
 
 
 
 
fcbf538
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6324708
 
 
fcbf538
6324708
 
 
fcbf538
6324708
 
fcbf538
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Uploaded Files</title>
    <style>
        ul {
            list-style-type: none;
            padding: 0;
        }
        li {
            cursor: pointer;
            margin: 5px 0;
            padding: 5px;
            border: 1px solid #ccc;
            border-radius: 4px;
            background-color: #f9f9f9;
        }
        li:hover {
            background-color: #e9e9e9;
        }
    </style>
</head>
<body>
    <h1>Uploaded Files</h1>
    <ul>
        {% if current_path %}
            <li onclick="location.href='{{ url_for('list_files', path=current_path.rsplit('/', 1)[0]) }}'">.. (Go Up)</li>
        {% endif %}
        {% for file in files %}
            <li onclick="openItem('{{ file }}')">{{ file }}</li>
        {% endfor %}
    </ul>
    <a href="/">Back to Shell</a>

    <script>
        function openItem(item) {
            const currentPath = "{{ current_path }}";
            const newPath = currentPath ? currentPath + '/' + item : item;
            const fullPath = '/files/' + newPath;

            // Check if the item is a directory or a file
            const isDir = item.includes('.'); // 简单判断是否为文件
            if (!isDir) {
                // 如果是目录,导航到该目录
                location.href = fullPath;
            } else {
                // 如果是文件,下载该文件
                location.href = fullPath + '/' + item;
            }
        }
    </script>
</body>
</html>