mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-03 01:50:59 +08:00
42a9c2688f
* fix multiple file examples * format * fix * change demo name zip_files * change func names
25 lines
616 B
Python
25 lines
616 B
Python
import os
|
|
from zipfile import ZipFile
|
|
|
|
import gradio as gr
|
|
|
|
|
|
def zip_files(files):
|
|
with ZipFile("tmp.zip", "w") as zipObj:
|
|
for idx, file in enumerate(files):
|
|
zipObj.write(file.name, "file" + str(idx))
|
|
return "tmp.zip"
|
|
|
|
demo = gr.Interface(
|
|
zip_files,
|
|
gr.File(file_count="multiple"),
|
|
"file",
|
|
examples=[[[os.path.join(os.path.dirname(__file__),"files/titanic.csv"),
|
|
os.path.join(os.path.dirname(__file__),"files/titanic.csv"),
|
|
os.path.join(os.path.dirname(__file__),"files/titanic.csv")]]],
|
|
cache_examples=True
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|