2022-09-16 02:40:59 +08:00
|
|
|
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):
|
2023-02-18 07:31:02 +08:00
|
|
|
zipObj.write(file.name, file.name.split("/")[-1])
|
2022-09-16 02:40:59 +08:00
|
|
|
return "tmp.zip"
|
|
|
|
|
|
|
|
demo = gr.Interface(
|
|
|
|
zip_files,
|
2023-01-05 01:34:46 +08:00
|
|
|
gr.File(file_count="multiple", file_types=["text", ".json", ".csv"]),
|
2022-09-16 02:40:59 +08:00
|
|
|
"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()
|