Yuning Zhang commited on
Commit
c7c39a7
·
1 Parent(s): 1b58834

test drag

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -1,15 +1,15 @@
1
  import gradio as gr
2
 
3
- def process_file(file):
4
- # 处理上传的文件,例如读取内容
5
- with open(file.name, 'r') as f:
6
- content = f.read()
7
- return f"文件内容:\n{content}"
 
8
 
9
- # 创建一个可以拖拽上传文件的界面
10
  demo = gr.Interface(
11
- fn=process_file,
12
- inputs=gr.inputs.File(label="拖拽文件到这里"),
13
  outputs="text"
14
  )
15
 
 
1
  import gradio as gr
2
 
3
+ def process_files(files):
4
+ contents = []
5
+ for file in files:
6
+ with open(file.name, 'r') as f:
7
+ contents.append(f.read())
8
+ return "\n\n".join(contents)
9
 
 
10
  demo = gr.Interface(
11
+ fn=process_files,
12
+ inputs=gr.File(label="拖拽文件到这里", type="file", file_count="multiple"),
13
  outputs="text"
14
  )
15