Spaces:
Paused
Paused
| <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> | |