gradio/demo/zip_files/run.py
Dawood Khan 42a9c2688f
Fix Multiple File Examples (#2267)
* fix multiple file examples

* format

* fix

* change demo name zip_files

* change func names
2022-09-15 14:40:59 -04:00

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()