e2dew32 commited on
Commit
030ee81
·
verified ·
1 Parent(s): 1fe91c4

Upload 3 files

Browse files
Files changed (2) hide show
  1. Dockerfile +10 -0
  2. app.py +3 -2
Dockerfile ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+ RUN pip install --no-cache-dir -r requirements.txt
7
+
8
+ COPY app.py .
9
+
10
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
app.py CHANGED
@@ -80,8 +80,9 @@ except Exception as e:
80
  st.info("请确保 Hugging Face Token 已配置,且在 Space Settings 中设置了 HF_TOKEN secret。")
81
  tree = []
82
 
83
- files = sorted([f for f in tree if f.type == "file"], key=lambda x: x.path)
84
- dirs = sorted([f for f in tree if f.type == "directory"], key=lambda x: x.path)
 
85
 
86
  total_size = sum(getattr(f, "size", 0) or 0 for f in files)
87
  st.info(f"📊 {len(files)} 个文件 | {len(dirs)} 个目录 | 总大小: {format_size(total_size)}")
 
80
  st.info("请确保 Hugging Face Token 已配置,且在 Space Settings 中设置了 HF_TOKEN secret。")
81
  tree = []
82
 
83
+ # Distinguish files vs directories: folders have tree_id, files have blob_id
84
+ files = sorted([f for f in tree if hasattr(f, "blob_id")], key=lambda x: x.path)
85
+ dirs = sorted([f for f in tree if hasattr(f, "tree_id")], key=lambda x: x.path)
86
 
87
  total_size = sum(getattr(f, "size", 0) or 0 for f in files)
88
  st.info(f"📊 {len(files)} 个文件 | {len(dirs)} 个目录 | 总大小: {format_size(total_size)}")